age_categorize: Categorize Age into Groups

Description Usage Arguments Value Details See Also Examples

Description

age_categorize conveniently generates commonly used age groups from a continuous age variable

Usage

1
age_categorize(df, col_name = NULL, method = NULL, var_name = NULL)

Arguments

df

data frame containing an age variable.

col_name

a string character of the age variable name in df.

method

is a numeric code specifying the age groupin method. See Details for more information

Value

returns a data frame with new factor column of labels for the specified age-groups.

Details

There are five pre-established age groups that can be specified using the methods parameter. Method 1: 0, 1, ..., 119, 120+ (single year age groups) Method 2: <1, 0-4, ..., 70-74, 75+ (5 year age groups) Method 3: 0-4, 5-9, ..., 70-74, 75+ (5 year age groups) Method 4: <1, 1-4, ..., 95-99, 100+ (5 year age groups) Method 5: 0-4, 5-9, ..., 75-79, 80+ (UN demogratic standard) Method 6: 0-4, 5-9, 10-14, 15-59, 60+ (broad age groups) Method 7: 0-14, 15-59, 60+ (broad age groups)

The new column is generated using the mutate function from the dplyr package.

See Also

cut, dplyr::mutate

Examples

1
2
3
4
5
6
## Use of the \code{schizophrenia} dataset from the \code{HSAUR} package
## Not run: 
require(HSAUR)
age_categorize(schizophrenia, col_name = "age", method = 5)

## End(Not run)

smh-ej/XploreR documentation built on May 13, 2019, 4:46 p.m.