library(ggplot2) library(reshape2)
本实验主要用来支持第3章的写作。
tml <- read.csv("D:\\data\\thesis\\201610\\tmldata\\tml.csv",header = T) dim(tml)
names(tml)
unique(tml$观测站编号)
unique(tml$观测站名称)
unique(tml$日期)
unique(tml$小时)
unique(tml$分钟)
sort(unique(tml$时间序号))
table(tml$上下行方向,tml$CDH)
names(tml)
dim(tml)
tmlflow <- tml[,9:17] names(tmlflow)
summary(tmlflow)
boxplot(tmlflow,names = names(tmlflow),cex.axis=0.7,cex=0.7)
unique(tml$日期)
tml1001 <- tml[tml$日期=="01-10月-16",] tml1001flow <- tml1001[,9:17] dim(tml1001flow)
flowcolsums <- colSums(tml1001flow) flowcolsums <- as.data.frame(flowcolsums) colnames(flowcolsums) <- "flow" flowcolsums$name <- rownames(flowcolsums) flowcolsums$name <- factor(flowcolsums$name,levels = flowcolsums$name)
ggplot(data=flowcolsums,aes(x=name,y=flow))+ geom_bar(stat="identity",fill="steelblue")+ theme(legend.position="none")+ xlab("车辆类型")+ylab("交通流量")+ geom_text(aes(label=flowcolsums$flow),vjust=-0.5)+ theme(axis.text.x=element_text(size = 10,face="bold")) ggsave("D:\\王致远\\论文\\大论文\\实验\\绘图\\10月1日交通流量条形图.png",dpi=600)
研究分上下行对车流量的影响
unique(tml1001$上下行方向)
tml1001sflow <- tml1001[tml1001$上下行方向=="S",9:17] names(tml1001sflow)
flowcolsumsS <- colSums(tml1001sflow) flowcolsumsS <- as.data.frame(flowcolsumsS) colnames(flowcolsumsS) <- "flow" flowcolsumsS$name <- rownames(flowcolsumsS) flowcolsumsS$name <- factor(flowcolsumsS$name,levels = flowcolsumsS$name)
ggplot(data=flowcolsumsS,aes(x=name,y=flow))+ geom_bar(stat="identity",fill="steelblue")+ theme(legend.position="none")+ xlab("车辆类型")+ylab("交通流量")+ geom_text(aes(label=flowcolsumsS$flow),vjust=-0.5)+ theme(axis.text.x=element_text(size = 10,face="bold")) ggsave("D:\\王致远\\论文\\大论文\\实验\\绘图\\10月1日交通流量条形图.png",dpi=600)
names(tml1001)
mm <- tml1001[,c(3,6,8,9:17)] mm <- melt(data = mm,id=(c("日期","时间序号","CDH"))) mm$CDH <- as.factor(mm$CDH)
names(mm)
ggplot(mm,aes(x=mm$variable,y=mm$value,fill=mm$CDH))+ geom_bar(stat = "identity",position = "dodge")+ theme(legend.title=element_text("车道号"))+ xlab("车辆类型")+ylab("交通流量")+labs(fill="车道号")+ theme(axis.text.x=element_text(size = 10,face="bold")) ggsave("D:\\王致远\\论文\\大论文\\实验\\绘图\\10月1日分车道交通流量条形图.png",dpi=600)
table(tml$日期)
tmlall <- read.csv("D:\\data\\thesis\\201610\\tmldata\\tmlall.csv",header = T) dim(tmlall)
table(tmlall$日期)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.