Skip to content

plot spaghetti data

2 messages · Doran, Harold, Douglas Bates

#
There is interaction.plot(), but, the trellis graphics in lattice are
much better. You might want to check these out. 

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Marc Bernard
Sent: Friday, September 16, 2005 8:58 AM
To: r-help at stat.math.ethz.ch
Subject: [R] plot spaghetti data

Dear All,
 
I  wonder if there is an R function to plot longitudinal data (spaghetti
plots)...
I've seen the function "is.longitudinal" but without any succes...
 
Thanks a lot in advance,
 
Bernard

		
---------------------------------



______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
2 days later
#
To elaborate a bit on Harold's reply, the use of a "spaghetti plot"
for more than 4 or 5 groups is not recommended.  Consider the
longitudinal data "sleepstudy" in the Matrix package.  A spaghetti
plot can be produced by
Now compare this to the result of
which is a lattice plot with the data for each subject in a separate
panel.  Even better is to use
+        index.cond = function(x, y) coef(lm(y ~ x))[1])

where the panels are ordered according to a characteristic of the data
(the intercept for the per-subject regression line) rather than in the
more-or-less random order created by the subject number.


library(lattice)
xyplot(Reaction ~ Days
On 9/16/05, Doran, Harold <HDoran at air.org> wrote: