Hi all,

Using xyplot I want to print to Y variables (y1, y2) versus X, conditional
on the group.
How can I obtain a line (type="l") for one relationship (ie. y1 ~ x) and
points (type="p") for the other (y2 ~ x) ?

library(lattice)

# create some sample data
df<-data.frame(group=as.factor(c(rep("a",4), rep("b",4))), # grouping
variable for conditional plots
    x=c(1:4,1:4), # x variable
    y1=rnorm(4,0,1), # y1
    y2=rnorm(4,0,1)) # y2


# Basically I want this plot, but then for y1~x points and for y2~x lines.
xyplot(y1+y2 ~ x|group, data=df)

# This works, but then I get the same plot in the two grouping windows
because conditioning is lost in the panel function.
xyplot(y1+y2 ~ x|group, data=df, type="l",
    panel=function(...){panel.xyplot(df$x,df$y1);
            panel.xyplot(df$x,df$y1, type="l")})

Thanks for your help.

Coen

	[[alternative HTML version deleted]]

