I'm not sure you can do that data aggregation in barplot directly (a quick skim doesn't reveal anything in the documentation that suggests it to me, thought I might have missed it) though I think this does what you are talking about:
barplot(sapply(unique(rownames(mdat)), function(n) colSums(mdat[n,,drop=F])), col = rainbow(2)) Michael On Thu, Nov 10, 2011 at 9:21 PM, Diviya Smith <diviya.sm...@gmail.com> wrote: > Hello there, > > I have a question regarding bar plots. I am trying to plot the data from > the following matrix as a barplot - > > # input data > mdat <- matrix(c(0.1,0.9,0.9,0.1,0.5,0.5,0.45,1-0.45,0.6,0.4,0.8,0.2), nrow > = 6, ncol=2, byrow=TRUE, > + dimnames = list(c("Mon", "Mon", "Tues", "Tues", "Thurs", > "Friday"), > + c("C.1", "C.2"))) > > # plot > > barplot(t(as.matrix(mdat)), col=rainbow(2), ylab="Sales", names.arg = > rownames(mdat), border=NA, cex.names=0.5) > > > I am using names.arg to print the label for the bars. However, I would like > to group all the entries for the Mon and print the label only once. Is > there a way to do this? The documentation for barplots suggests that this > can be done but I was not able to figure it out. Please help. > > > Thanks in advance, > > Diviya > > [[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. > ______________________________________________ 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.