View source: R/fig_poppyramid.R
fig_poppyramid | R Documentation |
Print a population pyramid
fig_poppyramid(
df,
var_age,
var_sex,
x_axis = c("n", "pct"),
age_plus = 100,
age_by = 5
)
df |
a data frame of individual survey data, where each row is an individual |
var_age |
a string (length 1) of the name of the age column |
var_sex |
a string (length 1) of the name of the sex column |
x_axis |
a string (length 1) indicating whether to use absolute numbers or sample percentage on the x-axis. Choices are |
age_plus |
a numeric value (length 1) indicating the age that is the first value of the oldest age group. Default is 100, for the last age group to be 100+ |
age_by |
a numeric value (length 1) indicating the width of each age group, in years. Default is 5. |
A population pyramid gives an image of the age and sex distribution of a population.
The function divides the var_age
variable into intervals of width age_by
.
A population pyramid figure
Other figure functions:
fig_LID()
,
fig_density()
,
fig_dist()
fig_poppyramid(df_adults, "age", "sex")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.