Title: | Draw Population Pyramid |
---|---|
Description: | Drawing population pyramid using (1) data.frame or (2) vectors. The former is named as pyramid() and the latter pyramids(), as wrapper function of pyramid(). pyramidf() is the function to draw population pyramid within the specified frame. |
Authors: | Minato Nakazawa <[email protected]> |
Maintainer: | Minato Nakazawa <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.5 |
Built: | 2025-02-21 04:44:04 UTC |
Source: | https://github.com/cran/pyramid |
The data gives the populations of Gunma Prefecture, Japan for each age of 0 to 108, males and females separately according to the population census 2005.
GunmaPop2005
GunmaPop2005
A data frame with 109 observations and 3 variables.
[, 1] |
Males |
numeric | Age specific population of males in 2005 Gunma Pref. |
[, 2] |
Females |
numeric | Age specific population of females in 2005 Gunma Pref. |
[, 3] |
Ages |
numeric | Ages from 0 to 108. |
http://www.e-stat.go.jp/SG1/estat/List.do?bid=000001005042&cycode=0.
The data gives the populations of Gunma Prefecture, Japan for each age of 0 to 108, males and females separately according to the population census 2010.
GunmaPop2010
GunmaPop2010
A data frame with 109 observations and 3 variables.
[, 1] |
Males |
numeric | Age specific population of males in 2010 Gunma Pref. |
[, 2] |
Females |
numeric | Age specific population of females in 2010 Gunma Pref. |
[, 3] |
Ages |
numeric | Ages from 0 to 108. |
Drawing population pyramid using data.frame. Detailed explanation is given in Japanese at http://minato.sip21c.org/swtips/R.html#PYRAMID.
pyramid(data, Laxis=NULL, Raxis=NULL, AxisFM="g", AxisBM="", AxisBI=3, Cgap=0.3, Cstep=1, Csize=1, Llab="Males", Rlab="Females", Clab="Ages", GL=TRUE, Cadj=-0.03, Lcol="Cyan", Rcol="Pink", Ldens=-1, Rdens=-1, main="", ...)
pyramid(data, Laxis=NULL, Raxis=NULL, AxisFM="g", AxisBM="", AxisBI=3, Cgap=0.3, Cstep=1, Csize=1, Llab="Males", Rlab="Females", Clab="Ages", GL=TRUE, Cadj=-0.03, Lcol="Cyan", Rcol="Pink", Ldens=-1, Rdens=-1, main="", ...)
data |
A data.frame including left pyramid numbers in the 1st column and and right pyramid numbers in the 2nd column, where the numbers of males in each age-class are usually given to left numbers and those of females are to right numbers. If the data.frame includes 3rd column, it is used as age-class labels, otherwise the row.names(data) is used as age-class labels. |
Laxis |
A vector of axis for left pyramid. If missing, automatically given using pretty(). |
Raxis |
A vector of axis for right pyramid. If missing, Laxis is used. |
AxisFM |
A format code of formatC for plotting axis. If missing, "g" is used. |
AxisBM |
A big.mark of formatC for plotting axis. If missing, none. |
AxisBI |
A big.interval number of formatC for plotting axis. Default is 3 |
Cgap |
The width of center gap (as ratio to each panel) to draw age-class. Default is 0.3 |
Cstep |
The interval to write the labels of age classes. Default is 1 |
Csize |
The font size factor to write the labels of age classes. Default is 1 |
Cadj |
The vertical adjustment factor for the labels of age classes. Default is -0.03 |
Llab |
The label of the left pyramid. Default is "Males". |
Rlab |
The label of the right pyramid. Default is "Females". |
Clab |
The label of the center age-class. Default is "Ages". |
GL |
Logical value to draw the vertical dotted lines. Default is TRUE. |
Lcol |
The color of the left pyramid. Default is "Cyan". |
Ldens |
The density of hatching lines (/inch) for left pyramid. Default is -1, when the pyramid will be filled. |
Rcol |
The color of the right pyramid. Default is "Pink". |
Rdens |
The density of hatching lines (/inch) for right pyramid. Default is -1, when the pyramid will be filled. |
main |
The main title of the pyramid. |
... |
Other options. |
Minato Nakazawa [email protected] http://minato.sip21c.org/
ages <- c('0-9','10-19','20-29','30-39','40-49','50-59','60-') males <- c(34,19,11,11,8,7,5) females <- c(26,25,16,11,7,5,1) data <- data.frame(males,females,ages) pyramid(data) # another example py.Males <- c(80,40,30,20,10) names(py.Males) <- c('0-9','10-19','20-29','30-39','40-') py.Females <- c(60,50,40,30,5) names(py.Females) <- names(py.Males) py.df <- data.frame(py.Females,py.Males) pyramid(py.df,Llab="Females",Rlab="Males",Lcol="navy", Ldens=5, Rcol="red", Rdens=10, GL=FALSE,main="An example of population pyramid\n with auto-axis") # GunmaPop2005 is included in this package. pyramid(GunmaPop2005,Llab="Males",Rlab="Females",Clab="",Laxis=seq(0,20000,len=5), AxisFM="d", AxisBM=",", Csize=0.8, Cstep=10, main="Population pyramid of Gunma Prefecture\n (Data: Census 2005, total by gender)")
ages <- c('0-9','10-19','20-29','30-39','40-49','50-59','60-') males <- c(34,19,11,11,8,7,5) females <- c(26,25,16,11,7,5,1) data <- data.frame(males,females,ages) pyramid(data) # another example py.Males <- c(80,40,30,20,10) names(py.Males) <- c('0-9','10-19','20-29','30-39','40-') py.Females <- c(60,50,40,30,5) names(py.Females) <- names(py.Males) py.df <- data.frame(py.Females,py.Males) pyramid(py.df,Llab="Females",Rlab="Males",Lcol="navy", Ldens=5, Rcol="red", Rdens=10, GL=FALSE,main="An example of population pyramid\n with auto-axis") # GunmaPop2005 is included in this package. pyramid(GunmaPop2005,Llab="Males",Rlab="Females",Clab="",Laxis=seq(0,20000,len=5), AxisFM="d", AxisBM=",", Csize=0.8, Cstep=10, main="Population pyramid of Gunma Prefecture\n (Data: Census 2005, total by gender)")
Drawing population pyramid using data.frame. Detailed explanation is given in Japanese at http://minato.sip21c.org/swtips/R.html#PYRAMID.
pyramidf(data, Laxis=NULL, Raxis=NULL, frame=c(-1.15, 1.15, -0.05, 1.1), AxisFM="g", AxisBM="", AxisBI=3, Cgap=0.3, Cstep=1, Csize=1, Llab="Males", Rlab="Females", Clab="Ages", GL=TRUE, Cadj=-0.03, Lcol="Cyan", Rcol="Pink", Ldens=-1, Rdens=-1, main="", ...)
pyramidf(data, Laxis=NULL, Raxis=NULL, frame=c(-1.15, 1.15, -0.05, 1.1), AxisFM="g", AxisBM="", AxisBI=3, Cgap=0.3, Cstep=1, Csize=1, Llab="Males", Rlab="Females", Clab="Ages", GL=TRUE, Cadj=-0.03, Lcol="Cyan", Rcol="Pink", Ldens=-1, Rdens=-1, main="", ...)
data |
A data.frame including left pyramid numbers in the 1st column and and right pyramid numbers in the 2nd column, where the numbers of males in each age-class are usually given to left numbers and those of females are to right numbers. If the data.frame includes 3rd column, it is used as age-class labels, otherwise the row.names(data) is used as age-class labels. |
Laxis |
A vector of axis for left pyramid. If missing, automatically given using pretty(). |
Raxis |
A vector of axis for right pyramid. If missing, Laxis is used. |
frame |
A vector of frame c(x-left, x-right, y-bottom, y-top), to draw pyramid. Default frame is same as |
AxisFM |
A format code of formatC for plotting axis. If missing, "g" is used. |
AxisBM |
A big.mark of formatC for plotting axis. If missing, none. |
AxisBI |
A big.interval number of formatC for plotting axis. Default is 3 |
Cgap |
The width of center gap (as ratio to each panel) to draw age-class. Default is 0.3 |
Cstep |
The interval to write the labels of age classes. Default is 1 |
Csize |
The font size factor to write the labels of age classes. Default is 1 |
Cadj |
The vertical adjustment factor for the labels of age classes. Default is -0.03 |
Llab |
The label of the left pyramid. Default is "Males". |
Rlab |
The label of the right pyramid. Default is "Females". |
Clab |
The label of the center age-class. Default is "Ages". |
GL |
Logical value to draw the vertical dotted lines. Default is TRUE. |
Lcol |
The color of the left pyramid. Default is "Cyan". |
Ldens |
The density of hatching lines (/inch) for left pyramid. Default is -1, when the pyramid will be filled. |
Rcol |
The color of the right pyramid. Default is "Pink". |
Rdens |
The density of hatching lines (/inch) for right pyramid. Default is -1, when the pyramid will be filled. |
main |
The main title of the pyramid. |
... |
Other options. |
Minato Nakazawa [email protected] http://minato.sip21c.org/
# GunmaPop2005 and GumaPop2010 are included in this package. plot(c(0,100), c(0,100), type="n", frame=FALSE, axes=FALSE, xlab="", ylab="", main="Population pyramid of Gunma prefecture") # overlay pyramidf(GunmaPop2005, frame=c(10, 75, 0, 90), Clab="", Lcol="skyblue", Rcol="pink", Cstep=10, Laxis=0:4*5000, AxisFM="d") pyramidf(GunmaPop2010, frame=c(10, 75, 0, 90), Clab="", Lcol="deepskyblue", Rcol="deeppink", Ldens=10, Rdens=10, Cstep=10, Laxis=0:4*5000, AxisFM="d") legend("right", fill=c("skyblue","pink","deepskyblue","deeppink"), density=c(NA,NA,10,10), legend=c("Male 2005", "Female 2005", "Male 2010", "Female 2010"), cex=0.8)
# GunmaPop2005 and GumaPop2010 are included in this package. plot(c(0,100), c(0,100), type="n", frame=FALSE, axes=FALSE, xlab="", ylab="", main="Population pyramid of Gunma prefecture") # overlay pyramidf(GunmaPop2005, frame=c(10, 75, 0, 90), Clab="", Lcol="skyblue", Rcol="pink", Cstep=10, Laxis=0:4*5000, AxisFM="d") pyramidf(GunmaPop2010, frame=c(10, 75, 0, 90), Clab="", Lcol="deepskyblue", Rcol="deeppink", Ldens=10, Rdens=10, Cstep=10, Laxis=0:4*5000, AxisFM="d") legend("right", fill=c("skyblue","pink","deepskyblue","deeppink"), density=c(NA,NA,10,10), legend=c("Male 2005", "Female 2005", "Male 2010", "Female 2010"), cex=0.8)
Drawing population pyramid using vectors. Detailed explanation is given in Japanese at http://minato.sip21c.org/swtips/R.html#PYRAMID.
pyramids(Left, Right, Center=NULL, ...)
pyramids(Left, Right, Center=NULL, ...)
Left |
A vector of the numbers of people given for the left pyramid. |
Right |
A vector of the numbers of people given for the right pyramid. |
Center |
If given, a vector of the age-class labels to be drawn in center. If not given, names(Left) is used instead. |
... |
This is the wrapper function for pyramid(). All options for pyramid() can be passed. |
Minato Nakazawa [email protected] http://minato.sip21c.org/
py.Males <- c(80,40,30,20,10) names(py.Males) <- c('0-9','10-19','20-29','30-39','40-') py.Females <- c(60,50,40,30,5) pyramids(Left=py.Males, Llab="Males", Right=py.Females, Rlab="Females", Laxis=c(0,50,100), main="An example of population pyramid\n with fixed axis")
py.Males <- c(80,40,30,20,10) names(py.Males) <- c('0-9','10-19','20-29','30-39','40-') py.Females <- c(60,50,40,30,5) pyramids(Left=py.Males, Llab="Males", Right=py.Females, Rlab="Females", Laxis=c(0,50,100), main="An example of population pyramid\n with fixed axis")