I spent some more time to understand the examples .. it helped a bit. 

But there is still one issue.

Taking example data (my first on, hope it is not confusing ;-)  ) like:


library(latticeExtra)
library(zoo)


#  example Data

timeVect1=seq(as.Date("1990-01-01"), as.Date("2010-12-31"), by="day")
timeVect2=seq(as.Date("1993-01-01"), as.Date("2010-12-31"), by="day")

df1=data.frame(a=runif(length(timeVect1), max=200),
b=runif(length(timeVect1), max=250))
df2=data.frame(a=runif(length(timeVect2), max=2),
b=runif(length(timeVect2), max=1.5))

ts1=zoo(df1, timeVect1)
ts2=zoo(df2, timeVect2)


# Adding some NA values

ts1$a[sample(1:trunc(length(timeVect1)/2), 2000)]=NA
ts1$b[sample(trunc(length(timeVect1)/2):length(timeVect1), 2000)]=NA

ts2$b[sample(1:trunc(length(timeVect2)/2), 2000)]=NA
ts2$a[sample(trunc(length(timeVect2)/2):length(timeVect2), 2000)]=NA




xyplot(ts1, panel = function(x, y, ...) {
        panel.grid(h = 10, v = 10, col = "grey", lty = 3)
        panel.xblocks(x, is.na(y), ..., col="RED")
panel.xyplot(x, y, ...)
})

So I managed to plot the missing data of ts1 to the corresponding panel,
but, how do I add the missing data from ts2 to the plot that show the
data from ts1 for the columns a and b??

Thanks for your efforts. 

Stefan




On Tue, 2012-03-06 at 08:33 -0500, R. Michael Weylandt wrote: 

> Type at your console:
> 
> library(lattice)
> example(xyplot.zoo)
> 
> I think the second and third do what you were asking. Otherwise,
> please describe in more detail what you mean about "add other
> variables to each panel" -- how do you want these displayed and what
> sort of variables are they?
> 
> On Tue, Mar 6, 2012 at 4:20 AM, Stefan Luedtke <[email protected]> 
> wrote:
> > Dear List,
> >
> > I managed to solve a part of my problem. Anyway, I still do not
> > understand how to use the lattice package the right way.
> >
> > An example:
> >
> > I do have multiple stations (say, with climatological data) and I want
> > to plot each station on its on panel.  I managed to do this of course
> > with one variable.
> >
> > What I want to do:
> >
> > 1) Add other variables to each panel, that worked as well, but a bit by
> > chance.
> >
> > 2) Add an panel.xblocks to each panel that show the data gaps of any
> > variable but not the first.
> >
> > If any of you could provide a minimal example.
> >
> >
> > Cheers,
> >
> > Stefan
> >
> > On Fri, 2012-03-02 at 14:15 -0800, sluedtke wrote:
> >
> >> Dear List,
> >>
> >> I am struggling with the trellis graphic. A similar problem was mentioned
> >> here:
> >>
> >> http://r.789695.n4.nabble.com/R-How-can-you-get-N-replicates-of-a-multi-screen-multivariate-time-series-plot-td811850.html
> >>
> >>
> >> I do have 2 time series data sets. The 2 time series differ in some orders
> >> of magnitude. I managed to plot them into 1 graph, but, since the data is
> >> that different, on of the data set appears as a line only, well almost. So 
> >> I
> >> would need to set a second y axis before, that is scaled to the second data
> >> set.
> >>
> >> I know how to do it with the usual plot.window routine or something 
> >> similar,
> >> but not with the trellis graphic of the "lattice" package.
> >>
> >> Thanks in advance!
> >>
> >> stefan
> >>
> >>
> >> --
> >> View this message in context: 
> >> http://r.789695.n4.nabble.com/times-series-trellis-plot-tp4440032p4440032.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> ______________________________________________
> >> [email protected] 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]]
> >
> > ______________________________________________
> > [email protected] 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]]

______________________________________________
[email protected] 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.

Reply via email to