书籍页数统计对collect_df中的时间、页数进行处理,并按月计算页数之和,注意有些书籍没有页数信息,无法计算在内,以缺失值NA处理,使用ggplot2绘制树状图如下:01pages<-as.integer(gsub('[页 ]','',collect_df$pages))02pg_df<-data.frame(collect_df$title,pages,03month=substr(collect_df$reading_date,1,7),04year=substr(collect_df$reading_date,1,4))05pg_s<-tapply(pg_df$pages,pg_df$month,sum,na.rm=T)06pg_sdf<-data.frame(pages=pg_s[],month=names(pg_s),year=substr(names(pg_s),1,4))0708ggplot(pg_sdf, aes(x=month, fill=year,colour=pages))+09geom_bar(stat="identity", ymin=0, aes(y=pages, ymax=pages),position="dodge")+10geom_text(aes(x=month, y=pages, ymax=pages,11label=pages,hjust
...
继续阅读
(24)