a2g | R Documentation |
Function that converts numeric age values to user defined age groups.
a2g(ages, mydist)
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. |
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.
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"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.