| Type: | Package | 
| Title: | Age Grouping Functions | 
| Version: | 1.0.0 | 
| Maintainer: | Austin Anders <nobilisvenator@hotmail.com> | 
| Description: | Pair of simple convenience functions to convert a vector of birth dates to age and age distributions. These functions may be helpful when related age and custom age distributions are desired given a vector of birth dates. | 
| License: | MIT + file LICENSE | 
| Encoding: | UTF-8 | 
| NeedsCompilation: | no | 
| Packaged: | 2022-10-29 17:46:28 UTC; NFNT | 
| Author: | Austin Anders [aut, cre] | 
| Repository: | CRAN | 
| Date/Publication: | 2022-10-31 14:10:17 UTC | 
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"
Date to Age
Description
Function that converts a Date class vector of birth date values to numeric age values. This function is preparative to the a2g function.
Usage
d2a(bd)
Arguments
| bd | Vector of Date class values. The date "yyyy-mm-dd" format is expected. | 
Value
Returns a numeric class vector object of ages if the function is provided a Date class object. The function will otherwise return an error message stating that the function requires a Date class object.
Examples
datevals <- as.Date(c("2019-01-01","1920-12-12","1980-02-02","1991-03-03" ))
d2a(datevals)
# > d2a(datevals)
# [1]  3 101  42  31