powered by
Print a population pyramid
fig_poppyramid( df, var_age, var_sex, x_axis = c("n", "pct"), age_plus = 100, age_by = 5 )
A population pyramid figure
a data frame of individual survey data, where each row is an individual
a string (length 1) of the name of the age column
a string (length 1) of the name of the sex column
a string (length 1) indicating whether to use absolute numbers or sample percentage on the x-axis. Choices are "n" (default) or "pct".
"n"
"pct"
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+
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.
var_age
age_by
Other figure functions: fig_LID(), fig_density(), fig_dist()
fig_LID()
fig_density()
fig_dist()
fig_poppyramid(df_adults, "age", "sex")
Run the code above in your browser using DataLab