if (interactive() && require("dplyr") && require("epidict")) {
withAutoprint({
set.seed(50)
dat <- epidict::gen_data("Cholera", n = 100, org = "MSF")
ages <- dat %>%
select(starts_with("age")) %>%
mutate(age_years = age_categories(age_years, breakers = c(0, 5, 10, 15, 20))) %>%
mutate(age_months = age_categories(age_months, breakers = c(0, 5, 10, 15, 20))) %>%
mutate(age_days = age_categories(age_days, breakers = c(0, 5, 15)))
ages %>%
group_age_categories(years = age_years, months = age_months, days = age_days) %>%
pull(age_category) %>%
table()
})
}
Run the code above in your browser using DataLab