[R] overlaying zoo plots in lattice

A Duranel arnaud.duranel.09 at ucl.ac.uk
Fri Jan 11 20:27:33 CET 2013


Hello

Let's say I have a multivariate zoo timeseries (synchronised automatic
loggers at different places):

library(zoo)
library(lattice)
library(latticeExtra)

x<-zoo(data.frame(a=rnorm(100), c=rnorm(100), b=rnorm(100)),
seq(from=as.Date("2010-01-01"), by="day", length.out=100))


and a dataframe with manual control points at variable dates:

y<-data.frame(ID=rep(c("b", "c", "a"),33), value=rep(c(-2, 0, 2), 33))
y$date<-seq(from=as.Date("2010-01-01"), by="day", length.out=99)

I would like to create a lattice graph with one panel per column of the zoo
timeseries, and overlay on each of them the control points that correspond
to it, on the basis of the "ID" factor in the dataframe that matches the
column names of the zoo timeseries. 
I tried this:

xyplot(x)+as.layer(xyplot(value~date|ID, y))

Unfortunately the points are not placed according to the name of the panels
(and of the column names of the zoo timeseries), but to the alphabetical
order of the "ID" factor it seems.

Any help will be much appreciated!

Arnaud



--
View this message in context: http://r.789695.n4.nabble.com/overlaying-zoo-plots-in-lattice-tp4655281.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list