options(stringsAsFactors = F)
library(Mreport) library(ggplot2)
load_base() load_sample_base()
jd201805 <- read.csv("D:\\data\\sx_raw\\交调数据\\jd2018_05.csv") dim(jd201805)
jd201805 <- caculate_equivalent(jd201805)
jd201805s <- select_atts(jd201805)
jd201805all <- handle_mergeline(jd201805s,station_line)
jd <- handle_mergesample(jd201805all,sample_base) names(jd)
jdnew <- jd[jd$index %in% station_use,] dim(jdnew)
x_wmean <- ddply(jdnew,c("citygroup"),summarise,Wmean_cars=weighted.mean(cars,w=mileage)) x_wmean <- x_wmean[order(x_wmean$Wmean_cars),] rownames(x_wmean) <- 1:nrow(x_wmean) x_wmean <- na.omit(x_wmean);x_wmean
x_factor <- factor(as.integer(rownames(x_wmean)),labels = x_wmean$citygroup)
x_mean <- ddply(jdnew,c("citygroup"),summarise,mean_cars=weighted.mean(cars)) x_mean <- x_mean[order(x_mean$mean_cars),];x_mean
有一定的差异。总体来说加权的偏小。
ggplot(data=x_wmean,aes(x=x_factor,y=Wmean_cars))+ geom_bar(fill="steelblue",stat = "identity")+ theme(axis.text.x = element_text(size=10,angle = 15))+ xlab("城市群")+ylab("加权平均月均日交通量")
caculate_carsmean(jdnew,"citygroup")
caculate_passcarsmean(jdnew,"citygroup")
caculate_frecarsmean(jdnew,"citygroup")
gg_boxplot(x,xangle = 15,xlab="城市群",ylab="月均日")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.