Parses age descriptions written in Chinese and converts them into numeric values expressed in years, months, or days. It interprets age strings containing Chinese characters such as (years), (months), and (days), and converts them to a numeric vector representing age in the specified unit.
tidy_age(x, unit = "year")
A numeric vector representing ages in the specified unit:
year: Truncated age in years.
month: Truncated age in months.
day: Rounded age in days.
agedes <- c(
"50\u5c8110\u67083\u6708", "19\u5c815\u6708",
"1\u5c8130\u6708", "3\u670820\u6708", "30\u6708"
)
tidy_age(agedes, unit = "year")
#> [1] 50 19 3 1 2
tidy_age(agedes, unit = "month")
#> [1] 602 232 41 20 30
tidy_age(agedes, unit = "day")
#> [1] 18354 7092 1278 609 913