pyramid_chart解决中文乱码
library(tidyverse) library(lubridate) library(showtext) library(janitor) library(openxlsx) library(magrittr) library(hablar) library(readxl) library(ggcharts) showtext_auto(enable = TRUE) df <- readxl::read_excel('/mnt/c/users/xuefe/Downloads/grda_fnl_tj.xlsx',skip = 1) %>% pivot_longer(cols=`0岁`:`100岁`,names_to = 'age',values_to = 'count') %>% filter(单位=='合计' & age!='0岁') %>% mutate(age=str_remove_all(age,'岁')) %>% convert(num(age)) df_m <- df %>% mutate(age_group=cut(age, breaks =seq(0,110,by=3),include.lowest = F,right=T)) %>% group_by(age_group) %>% summarise(sumn=sum(count,na.rm = T)) %>% mutate(sex='男性') # right=T 左开右闭 # rihht=F 左闭右开 p_1 <- ggplot(data = df_m) + geom_bar(aes(age_group,sumn), fill = 'skyblue', stat="identity", position="dodge")+ xlab('年龄组') + ylab('男性人口数')+ coord_flip() df <- readxl::read_exce