[R] barchart with stacked and beside bars

chris20 bop07crb at sheffield.ac.uk
Wed Jan 20 14:10:17 CET 2010



Hi,
Is there a way to stack bars in a barchart as well as "beside" bars for the
same treatment? eg....

I have one barchart like this:

bio<-matrix(c(10,23,9,25),nrow=2,byrow=T)
ntreat<-c("n0","n96")
colnames(bio)<-ntreat
barplot(bio,beside=T)

now i want a similar barchart but with stacked bars:

ld<-matrix(c(25,25,50,10,30,60,15,35,50,30,30,40),nrow=4,byrow=T)
ntreat2<-c("n0","n96","n0","n96")
rownames(ld)<-ntreat2
typ<-c("gr","fo","le")
colnames(ld)<-typ

barplot(t(ld))

I can't work out how to put the same treatments side by side and keep "typ"
stacked.

Thanks,
Chris 


-- 
View this message in context: http://n4.nabble.com/barchart-with-stacked-and-beside-bars-tp1018374p1018374.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list