s-news
[Top] [All Lists]

Re: Trellis help

To: "Huso, Manuela" <manuela.huso@oregonstate.edu>
Subject: Re: Trellis help
From: Andreas Krause <stats@elmo.ch>
Date: Thu, 02 Apr 2009 10:09:15 +0200
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <0552C65FE0AE49458A43BB6538148C920124AAF9@SAGE.forestry.oregonstate.edu>
References: <49CB7853.30402@earthlink.net> <0552C65FE0AE49458A43BB6538148C920124AAF9@SAGE.forestry.oregonstate.edu>
Reply-to: stats@elmo.ch
User-agent: Thunderbird 2.0.0.12 (Windows/20080213)
Manuela,

not all details are given to give a precise answer, but here is a generic answer.

Combine your 3 time series into one and add an indicator variable similar to this:
value time dataset
11    0    1
where dataset is either 1, 2, or 3 to indicate the original data set.

Then you can do anything you want if you do something like this:

xyplot(value ~ time | z, data=x, alldata=x,
  colors=c("red", "green", "blue", "orange"),
  panel=function(x, y, ..., subscripts, alldata, colors=1:99)
  {
    this.data <- alldata[subscripts, ...]
    # gets you the data for the current panel

    # Now you can do whatever you want inside the panel, for example:
    for(index in unique(this.data$dataset))
    {
      data.sub <- this.data[this.data$dataset==index, ] # get one series
      panel.lines(data.sub$x, data.sub$y, col=colors[index]) # lines
  }
)

# The trick is to just pass the entire data set to the panel function and then extract the ones you want.

Note that you can calculate standard errors beforehand,

sdv <- aggregate(list("sdv"=x[, "value"]), x[, c("time", "dataset")],
        function(x) { x <- x[!is.na(x)]; return(sqrt(var(x))/length(x)) } )
x2 <- merge(x, sdv, all=TRUE)

or you do the calculation inside the panel function (!).

An extended example of such customization is shown in our book, The Basics of S-Plus, in the exercises and solutions of the chapter on "Trellis Graphics".

Hope this helps.

  Andreas


Huso, Manuela wrote:
Hello, all,

I would like to  make a trellis plot that has 3 lines (plus error bars
at certain points in each of the panels).  I have not seen an example of
this... Every example I have seen has only one line per plot.  I have
the equivalent of 3 time series measured on each experimental unit, and
I have 18 units, so I am looking to produce a panel of 6 rows X 3
columns, each with 3 lines (with vertical error bars at about 7
locations along each line).  Can anyone point me to a parallel example,
please?

Many thanks in advance!

Manuela

::<>::<>::<>::<>::<>::<>::<>::<>::<>::<>::<
Manuela Huso
Consulting Statistician
Department of Forest Ecosystems and Society
201H Richardson Hall
Oregon State University
Corvallis, OR   97331
ph: 541.737.6232
fx: 541.737.1393

-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Data
Analytics Corp.
Sent: Thursday, March 26, 2009 5:43 AM
To: s-news@lists.biostat.wustl.edu
Subject: [S] function miss is missing

Hi,

I discovered documentation for the function miss() in the language help
for S+ 8.0. This is suppose to show a missing data pattern display. When I copied the example to a script window, I got an error message
that miss can't be found.  What happened to miss?

Thanks,

Walt



--
________________________

Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
dataanalytics@earthlink.net
www.dataanalyticscorp.com

--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news




<Prev in Thread] Current Thread [Next in Thread>
  • Re: Trellis help, Andreas Krause <=