基于R目前,我有这样的代码:3变量堆叠barplot
### Uses the library ggplot2###
library("ggplot2")
library("reshape2")
### Reads in the CSV file to be plotted ###
plot <- read.csv("C:/Users/dam203/Desktop/Ongoing_Projects/output-1.csv")
### Makes R recognize that the X-axis has been pre-sorted so that GGPLOT2 does not sort alphabetically. ###
plot$Date <- factor(plot$Date, levels = plot$Date)
### Plots the Graph ###
ggplot(plot[which(plot$F.Sym.Onset>0),], aes(x=Date, y=F.Sym.Onset)) + geom_bar(stat="identity") + theme(axis.text.x=element_text(angle=90, hjust=1)) + ggtitle("Epidemic Pertussis Case Curve")
这是什么CSV文件中的数据看起来像一个小样本。但是,实际CSV文件中有更多的列和行。日期,C.Sym.Onset,F.Sym.Onset,D.Sym.Onset是我现在很感兴趣:
Date C.Sym.Onset F.Sym.Onset D.Sym.Onset Temp
6-Jan 2 1 47
7-Jan 1 3 2 57
8-Jan 1 54
9-Jan 58
10-Jan 1 59
由于代码的正上方,它会忽略日期没有F唯一列.Sym.Onset并绘制根据图表组织的给定日期的案例数量,而不是ggplots默认的字母顺序。
我的问题是,我该怎么做才能在垂直堆积的条形图上绘制C.Sym.onset,F.Sym.Onset和D.Sym.Onset?
这是一个图表的副本我的剧本目前从产生CSV具有完整的数据文件:
感谢您的帮助!