[R] Need some quick help with lattice - barchart

From: Ghosh, Sandeep <sghosh_at_lexgen.com>
Date: Fri 06 May 2005 - 04:10:06 EST


For the following code below, the x-axis ticks are 1,2,3,4,5,6,7 when I was expection them to be 1,2,8,9,10,11,12. Please help me figure out where is the mistake.

library(lattice)

testdata <- as.data.frame(t(structure(c(

1,2005,9.24,6.18,634,
2,2005,8.65,6.05,96,
8,2004,6.81,6.51,16,
9,2004,9.0,7.29,8,
10,2004,8.84,6.18,524,
11,2004,8.54,6.35,579,

12,2004,9.97,6.3,614,
12,2005,8.75,5.84,32,
), .Dim=c(5,8))))

colnames(testdata) <- c('month', 'year', 'mean','stdDev','miceCount') testdata$month <- as.numeric(testdata$month) testdata$year <- factor(testdata$year)
testdata <- testdata[do.call("order", testdata), ]

png('lexstar_3241.png', width=600, height=as.numeric(length(levels(testdata$year))*200), pointsize=8) trellis.par.set(theme = col.whitebg())

with(testdata, print(barchart(as.numeric(mean) ~ month | year, data=testdata,

    layout=c(1,length(levels(year))),
    horizontal=FALSE,
    scales=list(y=list(limits=c(1,max(as.numeric(mean))+max(as.numeric(stdDev))))),

    main='Marble Burying - Level I',
    xlab='Months',
    ylab='Mean',

    sd = as.numeric(as.character(stdDev)),     panel= function(x, y, ..., sd, subscripts) {
		panel.barchart(x, y, ...);
		sd <- sd[subscripts];
		panel.segments(as.numeric(x), y - sd, as.numeric(x), y + sd, col = 'red', lwd = 2);
	   }

)))

dev.off()

Any help is greatly appreciated...

Thanks,
Sandeep

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 06 04:22:48 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:36 EST