s-news
[Top] [All Lists]

Summary: Points + lines in trellis

To: S-News <s-news@lists.biostat.wustl.edu>
Subject: Summary: Points + lines in trellis
From: David Parkhurst <parkhurs@imap.iu.edu>
Date: Thu, 11 May 2006 11:30:13 -0400
User-agent: Thunderbird 1.5.0.2 (Windows/20060308)
I thank Naomi Robbins, Madeline Bauer, Matt Austin, and Richard Heiberger for their advice on my question, which was:

“I have data for four situations, and for each I have a few (c. 4--6) original data points, and about 100 points for non-linear functions fit to those data. (The functions differ among the situations.) Is there a way to use trellis to make a 2x2 grid of plots, each containing the raw data as points, and the fitted functions as lines?”

The answer that worked best for me was one that Richard sent off-list to me, namely:

observed <- data.frame(y=rnorm(12),
                       x=1:12,
                       case=c(1,1,1,2,2,2,3,3,3,3,4,4),
                       form=1)

aa <- data.frame(y=rnorm(14), x=1:14, case=1, form=2)
bb <- data.frame(y=rnorm(16), x=1:16, case=2, form=2)
cc <- data.frame(y=rnorm(17), x=1:17, case=3, form=2)
dd <- data.frame(y=rnorm(19), x=1:19, case=4, form=2)

tmp <- rbind(observed, aa, bb, cc, dd)
tmp$case <- factor(tmp$case)
tmp$form <- factor(tmp$form, labels=c("raw", "fit"))

xyplot(y ~ x | case, pch=16,
       panel=panel.superpose,
       group=form, type=c("p","l"), data=tmp)

Madeline’s suggestion to use print.trellis would likely also have worked well.

Thanks to all for your help.
Dave Parkhurst

<Prev in Thread] Current Thread [Next in Thread>
  • Summary: Points + lines in trellis, David Parkhurst <=