[R] Need help arranging the plot in different fashion than the default format
Marc Schwartz
MSchwartz at MedAnalytics.com
Fri Apr 22 23:36:37 CEST 2005
On Fri, 2005-04-22 at 16:19 -0500, Ghosh, Sandeep wrote:
> I want to change the way the plot is appearing in the barchart ..
>
> testdata <- as.data.frame(t(structure(c
> (1,2004,"LV1",3.8,2,87,2,2004,"LV1",3.2,3,28,3,2004,"LV1",3.4,3,88,4,2004,
>"LV1",3,2,26,5,2004,"LV1",3.8,2,87,6,2004,"LV1",3.2,3,28,7,2004,"LV1",3.4,3,
>88,8,2004,"LV1",3,2,26,9,2004,"LV1",3.8,2,87,10,2004,"LV1",3.2,3,28,11,2004,
>"LV1",3.4,3,88,12,2004,"LV1",3,2,26,1,2005,"LV1",3.8,2,87,2,2005,"LV1",3.2,3,
>28,3,2005,"LV1",3.4,3,88,4,2005,"LV1",3,2,26), .Dim=c(6,16))));
> colnames(testdata) <- c('month', 'year',
> 'dataset','mean','stdDev','miceCount');
> testdata[c("month", "mean")] <- lapply(testdata[c("month", "mean")],
> function(x) as.numeric(levels(x)[x]));
> testdata <- testdata[do.call("order", testdata), ];
> trellis.par.set(theme = col.whitebg());
> barchart(month ~ mean | year, data=testdata)
>
> I want to have the years come one below the other rather than next to
> each other which can be achieved by layout(c(1,2)), and the x axis to
> be the month and the y axis to be the mean. I would really appreciate
> if someone can tell me how to achieve this
>
> barchart(mean ~ month | year, data=testdata, layout=c(1,2)) #doing
> this is not producing the intended result
>
> Any suggestion and help is greatly appreciated..
I suspect you want:
barchart(mean ~ month | year, data = testdata, horizontal = FALSE,
layout=c(1,2)
Note the use of 'horizontal = FALSE'
HTH,
Marc Schwartz
More information about the R-help
mailing list