> > 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... > > Thanks for the help Felix! It was a bit obvious what the problem was and I apologize for not thinking about the error message more clearly. I am going to continue this as I think that it would be helpful if there was a working example of this type of plot. Unfortunately, I do not have it yet. The modified example below produced a stacked barplot with lovely error bars. However, I can't seem to produce a plot that doesn't stack the bars. stack=FALSE doesn't seem to have any effect. Any thoughts?
Thanks in advance. Sam #Generating the data library(lattice) temp <- abs(rnorm(81*5)) err <- as.data.frame(temp) err$section=c("down","down","down","mid","mid","mid", "up","up", "up") err$depth=c("Surface","D50", "2xD50") err$err.date=c("05/09/2009","12/09/2009","13/10/2009","19/10/2009","21/09/2009") err.split <- with(err, split(temp, list(depth,section, err.date))) #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, ly, uy, subscripts, pch = 16, ...) { x <- as.numeric(x) y <- as.numeric(y) ly <- as.numeric(ly[subscripts]) uy <- as.numeric(uy[subscripts]) panel.arrows(x, ly, x, uy, col = 'black', length = 0.25, unit = "native", angle = 90, code = 3) panel.barchart(x, y, pch = pch, ...) } se <-function(x) sqrt(var(x)/length(x)) err.ucl <- sapply(err.split, function(x) { st <- boxplot.stats(x) c(mean(x), mean(x) + se(x), mean(x) -se(x)) }) err.ucl <- as.data.frame(t(err.ucl)) names(err.ucl) <- c("mean", "upper.se", "lower.se") err.ucl$label <- factor(rownames(err.ucl),levels = rownames(err.ucl)) # add factor, grouping and by variables err.ucl$section=c("down","down","down","mid","mid","mid", "up","up", "up") err.ucl$depth=c("Surface","D50", "2xD50") s err.ucl$err.date=c("05/09/2009","12/09/2009","13/10/2009","19/10/2009","21/09/2009") #This produces the figure I am looking for minus the error bars. with(err.ucl, barchart(mean ~ err.date | section, group=depth, layout=c(1,3), horizontal=FALSE, scales=list(x=list(rot=45)), )) #OK, now that this work and the error bars are drawn, I am curious why the stack=TRUE doesn't produce each bar beside each other. with(err.ucl, barchart(mean ~ err.date| section, group=depth, layout=c(1,3), horizontal=FALSE, stack=FALSE, scales=list(x=list(rot=45)), ly=lower.se, uy=upper.se, auto.key = list(points = FALSE, rectangles = TRUE, space= "right", title = "Depth", border = TRUE), #auto.key=TRUE, prepanel=prepanel.ci, panel=panel.superpose, panel.groups=panel.ci )) -- ***************************************************** Sam Albers Geography Program University of Northern British Columbia 3333 University Way Prince George, British Columbia Canada, V2N 4Z9 phone: 250 960-6777 ***************************************************** [[alternative HTML version deleted]] ______________________________________________ R-help@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.