Hi,

 

How can I add legends in the "xyplot" function, in the "lattice" library?
Here is a simulation example:

 

x <- runif(90)

z <- sample(1:3, 90, rep=T)

y <- rnorm(90, mean = x^2 + z, sd=1)

 

library(lattice)

trellis.par.set(col.whitebg())

xyplot(y ~x, groups=as.factor(z), type = c('p', 'smooth'), span = .67)

 

Thanks in advance,

Ravi.

 


	[[alternative HTML version deleted]]


