[R] Error Bars in lattice- barcharts

Felix Andrews felix at nfrac.org
Thu Apr 8 07:03:43 CEST 2010


On 20 February 2010 11:22, Sam Albers <tonightsthenight at gmail.com> wrote:

> #I've tried to alter the panel function according to the thread to produce
> vertical error bars in my barcharts
>
> prepanel.ci <- function(x, y, ly, uy, subscripts, ...) {
>
>        y <- as.numeric(y)
>        ly <- as.numeric(ly[subscripts])
>         uy <- as.numeric(uy[subscripts])
>         list(ylim = range(y, uy, ly, finite = TRUE))
>     }
>
> panel.ci <- function(x, y, lx, ux, subscripts, pch = 16, ...) {
>         x <- as.numeric(x)
>         y <- as.numeric(y)
>         lx <- as.numeric(lx[subscripts])
>         ux <- as.numeric(ux[subscripts])
>
>         panel.arrows(x, ly, x, uy, col = 'black',
>                  length = 0.25, unit = "native",
>                  angle = 90, code = 3)
>         panel.barchart(x, y, pch = pch, ...)
>     }
>



> # Deepayan's original example. I am unsure how to diagnose the packet error.
> This is where I run into problems


Well, when the error message says "argument 'lx' is missing, with no
default", it really means that argument 'lx' is missing, with no
default. Your panel function has an argument 'lx', which you forgot to
change to 'ly' as you did with the prepanel function.

Hope that helps...


> with(err.ucl, barchart(mean ~ err.date | section, group=depth,
>         layout=c(1,3),
>         horizontal=FALSE,
>         scales=list(x=list(rot=45)),
>         ly=lower.se,
>         uy=upper.se,
>         prepanel=prepanel.ci,
>         panel=panel.superpose,
>         panel.groups=panel.ci
>         ))
>



-- 
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 4670
E: felix.andrews at anu.edu.au
CRICOS Provider No. 00120C
-- 
http://www.neurofractal.org/felix/



More information about the R-help mailing list