a2g {ageg} | R Documentation |
Age to Group
Description
Function that converts numeric age values to user defined age groups.
Usage
a2g(ages, mydist)
Arguments
ages |
Vector of Numeric class age values. |
mydist |
Vector of Character class age distributions. Values must be two integers separated by a hyphen. Remove any whitespaces on either side of the hyphen. |
Value
Returns a Character class vector object of age distribution values defined by the mydist argument. The function will otherwise return an error message stating that the function requires a numeric class object.
Examples
ages <- c(3, 101, 42, 32)
mydist <- c("5-10","11-20","21-30","31-40","41-50","51-60","61-70","71+")
a2g(ages, mydist)
# > a2g(ages, mydist)
# [1] NA "71+" "41-50" "31-40"
[Package ageg version 1.0.0 Index]