Skip to content
Prev 120442 / 398500 Next

xyplot for longitudinal data

On 7/17/07, Osman Al-Radi <osman.al.radi at gmail.com> wrote:
Create an interaction and specify the colors and symbols you want
explicitly. E.g.,

spcolors <- trellis.par.get("superpose.symbol")$col

df$subject <- factor(df$subject)
df$group <- factor(df$group)

with(df,
     xyplot(score~age, groups = interaction(subject, group),
            type = "l",
            col = rep(spcolors[1:nlevels(group)], each = nlevels(subject))))


Look at ?Rows, which might help in getting code that is a bit more
general (for instance, the code above may not work when groups has
more than 7 levels).

-Deepayan