Age Transforming Function

transform_age(age, type = "days", to = "years")

Arguments

age

a numeric vector with ages

type

type of the age vector, allowed values are days or years. defaults to 'days'

to

final format of age vector. allowed values are 'years', 'days', 'pw-N', and 'lg-N', where N is any number. 'pw' means power. e.g. pw-0.5 means sqrt(age), and 'lg' means log, e.g. lg-2 means log2(age). Defaults to 'years'.

Value

a vector with ages in the desired scale

Examples

agevec <- seq(1:20) transform_age(agevec, type = 'years', to = 'days')
#> [1] 365 730 1095 1460 1825 2190 2555 2920 3285 3650 4015 4380 4745 5110 5475 #> [16] 5840 6205 6570 6935 7300
transform_age(agevec, type = 'years', to = 'pw-0.25')
#> [1] 4.370924 5.197933 5.752459 6.181419 6.536055 6.840865 7.109642 7.350988 #> [9] 7.570662 7.772723 7.960152 8.135205 8.299636 8.454837 8.601933 8.741847 #> [17] 8.875349 9.003085 9.125604 9.243378
transform_age(agevec, type = 'years', to = 'lg-10')
#> [1] 2.562293 2.863323 3.039414 3.164353 3.261263 3.340444 3.407391 3.465383 #> [9] 3.516535 3.562293 3.603686 3.641474 3.676236 3.708421 3.738384 3.766413 #> [17] 3.792742 3.817565 3.841046 3.863323