s-news
[Top] [All Lists]

Q re. panel.superpose with trellis

To: <s-news@lists.biostat.wustl.edu>
Subject: Q re. panel.superpose with trellis
From: "Dave Atkins" <datkins@u.washington.edu>
Date: Fri, 30 Mar 2001 11:11:54 -0800
Organization: University of Washington
Hi all--

I'm using Splus 2000 R2 on Windows98

I'm working with longitudinal data on married couples.  I'd like to plot the
data with a smoothed line for each partner.  The following command will give
me one panel for males and one for females with a smoothed line in each:

xyplot(outcome ~ time | sex, data = df,
   panel = function(x, y) {
                 panel.grid()
     panel.xyplot(x,y)
     panel.abline(60, 0, lty = 2)
                 panel.loess(x, y, span = 1, degree = 2, family =
"gaussian")
        }, aspect = 0.75, xlab = "Time (in weeks)", ylab = "Outcome: Average
GDS/DAS T-score")

However, I'd like to plot the data in a single panel with separate smoothed
lines for each sex (different line types would be nice as well).  I've been
trying to work with panel.superpose to make this happen but can't quite seem
to figure it out.  Here was the code I have been working with, but it
doesn't work in its current incarnation:

xyplot(outcome ~ time, data = df, groups = sex,
   panel = function(x, y, groups, subscripts) {
                 panel.grid()
     panel.abline(60, 0, lty = 2)
                 panel.superpose(x, y, groups, subscripts)
                 panel.loess(x["Male",], y["Male",], span = 1, degree = 2,
family = "gaussian")
                 panel.loess(x["Female",], y["Female",], span = 1, degree =
2, family = "gaussian")
        }, aspect = 0.75, xlab = "Time (in weeks)", ylab = "Outcome: Average
GDS/DAS T-score")

Any suggestions appreciated.

best, dave

Dave Atkins
Center for Clinical Research
University of Washington
Email: datkins@u.washington.edu




<Prev in Thread] Current Thread [Next in Thread>
  • Q re. panel.superpose with trellis, Dave Atkins <=