年龄分组
cr %>%
filter(str_detect(shi,'^62')) %>%
group_by(shi) %>%
summarise(v1=sum(year>=18,na.rm = T),v2=sum(year<18,na.rm = T),v3=sum(year>=0),n=n())
cr %>%
mutate(age_group=case_when(
year<6 ~ '<6',
year>=6 & year<12 ~ '6-11',
year>=12 & year<15 ~ '12~14',
year>=15 & year<18 ~ '15-17',
year>=18 & year<59 ~ '18-59',
year>=60 & year<70 ~ '60-69',
year>=70 ~ '>=70')) %>%
filter(str_detect(shi,'^62')) %>%
group_by(age_group) %>%
summarise(n=n())
评论
发表评论