str(x) ; str(y) reveals
#‘zoo’ series ...
#  ..$ : chr [1:3] "a" "c" "b"                           ## HERE
#  Index:  Date[1:100], format: "2010-01-01" "2010-01-02" "2010-01-03"
"2010-01-04" ...
#'data.frame':    99 obs. of  3 variables:
# $ ID   : Factor w/ 3 levels "a","b","c":       ## HERE
# ...
#'

So change the levels of ID in y or in the plot call to fit the zoo object:
xyplot(x)+as.layer(xyplot(value~date|factor(ID,levels=c('a','c','b')), y))





On Fri, Jan 11, 2013 at 12:27 PM, A Duranel <arnaud.duranel.09@ucl.ac.uk>wrote:

> 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.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]


