plot_agepyramid: Plot Age Pyramid

View source: R/plot_agepyramid.R

plot_agepyramidR Documentation

Plot Age Pyramid

Description

This function plots an age pyramid based on specified age groupings and sex.

Usage

plot_agepyramid(
  df,
  age_grouping = NULL,
  filtering = NULL,
  file_path = NULL,
  wdth = NULL,
  hght = NULL,
  title_name = NULL
)

Arguments

df

Inputs a dataframe that has been processed and standardized by either the healthyr::format_mortality_current census or healthyr::format_nut_health_indicators functions.

age_grouping

Inputs an optional character value specifying a column name with age groupings. If nothing specified, it will use the recommended default 'age_group' which are 5-year groupings created by the healthyr functions.

filtering

Inputs an optional character value specifying a variable to filter the data for. This is useful if you want to only see the age pyramid for individuals meeting a certain criteria, like disability status. The filtering variable should be coded numerically as 0s and 1s, with the 1s being the population you want to plot.

file_path

Inputs an optional character value specifying the file path location to save an image of the plot. Recommended to specify as a .jpg or .png file.

wdth

Inputs an optional numeric value for the width of the image.

hght

Inputs an optional numeric value fo the height of the image.

title_name

Inputs an optional character value for the title of the plot.

Value

Returns a ggplot2 object.

Examples

## Not run: plot_agepyramid(df, age_grouping = "age_group", filtering = "disability3")

SaeedR1987/healthyr documentation built on July 4, 2023, 11:17 p.m.