2014-12-03 159 views
0

我想将现场值(线)的时间序列与特定日期的估计值的箱线图相结合。我试图理解这个“Add a line from different result to boxplot graph in ggplot2”的问题,但我的约会让我疯狂。有时候我只有原始的日期值,有时候只是估计值,有时候只是两个值。在R中绘制箱形图和一系列时间序列数据

我上传我的数据样本这里:

http://www.file-upload.net/download-9942494/estimated.txt.html

http://www.file-upload.net/download-9942495/insitu.txt.html

我如何可以创建两组数据,看起来像这样http://www.file-upload.net/download-9942496/desired_outputplot.png.html 到底是阴谋?

回答

0

我得到的帮助,有一个解决方案现在:

insitu <- read.table("insitu.txt",header=TRUE,colClasses=c("Date","numeric")) 
est <- read.table("estimated.txt",header=TRUE,colClasses=c("Date","numeric")) 


insitu.plot <- xyplot(insitu~date_fname,data=insitu,type="l", 
      panel=function(x,y,...){panel.grid(); panel.xyplot(x,y,...)},xlab=list(label="Date",cex=2)) 
est.plot <- xyplot(estimated~date,data=est,panel=panel.bwplot,horizontal=FALSE) 
both <- insitu.plot+est.plot 

update(both,xlim=range(c(est$date,insitu$date_fname))+c(-1,1),ylim=range(c(est$estimated,insitu$insitu)))