Pyramid plot function for creating population pyramids.
pyramid.plot( x, g, main = paste("Pyramid plot of", deparse(substitute(x)), "by", deparse(substitute(g))), xlab = paste(deparse(substitute(g)), "(", levels(as.factor(g))[1], "/", levels(as.factor(g))[2], ")"), ylab = deparse(substitute(x)), col = "white", ... )
x | Vector of ages (usually grouped) |
---|---|
g | Vector of groups (usually sex) |
main | Plot title |
xlab |
|
ylab |
|
col | Colours for bars. Either a single colour (default is
|
... | Other graphical parameters |
A table of x
by g
(invisible)
# Use pyramid.plot() on anthropometric data from a SMART survey in # Kabul, Afghanistan (dp.ex02) svy <- dp.ex02 pyramid.plot(svy$age, svy$sex)