[R] Lattice, stripplot (xyplot), plotting data with median line, numeric x-axis

Felix Andrews felix at nfrac.org
Sun Sep 27 13:22:41 CEST 2009


Hi David,

stripplot is for numeric vs categorical data
(and is a thin wrapper around xyplot).

Just change stripplot to xyplot and it will work.

-Felix


2009/9/27 Afshartous, David <DAfshartous at med.miami.edu>:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Felix Andrews / 安福立
Postdoctoral Fellow
Integrated Catchment Assessment and Management (iCAM) Centre
Fenner School of Environment and Society [Bldg 48a]
The Australian National University
Canberra ACT 0200 Australia
M: +61 410 400 963
T: + 61 2 6125 1670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/




More information about the R-help mailing list