2014-12-03 129 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)))