出生队列接种率处理

 library(tidyverse)

library(lubridate)

library(showtext)

library(janitor)

library(openxlsx)

library(magrittr)

library(hablar)

library(readxl)

library(ggcharts)

library(purrr)

showtext_auto(enable = TRUE)


`%nin%` = Negate(`%in%`)


df <- readxl::read_excel('/mnt/c/Users/xuefe/Downloads/gnldet_jzl.xlsx',sheet = 1,skip = 3) %>% 

  fill(c(`...1`,`...2`,`...3`),.direction='down') %>% 

  filter(`...3` %nin% c('总人数','全程接种')) %>% 

  select(starts_with('...')  | contains("接种率")) %>% 

  map_dfc(str_remove_all, pattern = "%") %>% 

  mutate_at(vars(contains("接种率")), as.numeric) %>% 

  select(-`接种率(%)...22`)


# df %>% 

#   write.xlsx('/mnt/c/Users/xuefe/Downloads/jzl.xlsx')


names(df) <- c('dqmc','bm','ym','jc','age_1','age_2','age_3','age_4','age_5','age_6','age_7','age_8','age_9',

               'age_10','age_11','age_12','age_13','age_14','age_15','age_16','age_17')


#1岁组,接种率小于90的县区统计

df %>% 

  group_by(bm) %>% 

  summarise(count=sum(age_1<90,na.rm = T)) %>% 

  arrange(bm) %>% 

  mutate(shi=str_sub(bm,1,4)) %>% 

  group_by(shi) %>% 

  summarise(n=n())


#2岁组,接种率小于90的县区统计

df %>% 

  group_by(bm) %>% 

  summarise(count=sum(age_2<90,na.rm = T)) %>% 

  arrange(bm) %>% 

  mutate(shi=str_sub(bm,1,4)) %>% 

  group_by(shi) %>% 

  summarise(n=n())



#乡镇

df <- readxl::read_excel('/mnt/c/Users/xuefe/Downloads/gnldet_jzl (2).xlsx',sheet = 1,skip = 3) %>% 

  fill(c(`...1`,`...2`,`...3`),.direction='down') %>% 

  filter(`...3` %nin% c('总人数','全程接种')) %>% 

  select(starts_with('...')  | contains("接种率")) %>% 

  map_dfc(str_remove_all, pattern = "%") %>% 

  mutate_at(vars(contains("接种率")), as.numeric) %>% 

  select(-`接种率(%)...22`)



names(df) <- c('dqmc','bm','ym','jc','age_1','age_2','age_3','age_4','age_5','age_6','age_7','age_8','age_9',

               'age_10','age_11','age_12','age_13','age_14','age_15','age_16','age_17')


#1岁组,接种率小于90的县区统计

df %>% 

  group_by(bm) %>% 

  summarise(count=sum(age_1<90,na.rm = T)) %>% 

  arrange(bm) %>% 

  mutate(shi=str_sub(bm,1,4)) %>% 

  group_by(shi) %>% 

  summarise(n=n())


评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理