[R] Lattice, stripplot (xyplot), plotting data with median line, numeric x-axis
Afshartous, David
DAfshartous at med.miami.edu
Sat Sep 26 20:05:40 CEST 2009
All,
On p.52 of Deepayan Sarkar's Lattice book there is a nice plot of showing
residuals with median lines superimposed or various groups:
library("lattice")
stripplot(sqrt(abs(residuals(lm(yield~variety+year+site)))) ~ site,
data = barley, groups = year, jitter.data = TRUE, type = c("p", "a"), fun =
median)
Suppose we wanted to make a similar plot for a numeric x-axis. Is there any
way to do this with stripplot or does one have to xyplot and presumably
panel functionality to get the median line? This does not work:
barley$site.numeric =as.numeric(barley$site)
stripplot(sqrt(abs(residuals(lm(yield~variety+year+site)))) ~ site.numeric,
data = barley, groups = year, jitter.data = TRUE, type = c("p", "a"),
fun = median)
Any tips much appreciated. For my data I had made my x-axis a factor but
forgot that this doesn't work since the intervals are not equally spaced.
Thanks!
David
More information about the R-help
mailing list