The documentation for bar plots includes -

names.arga vector of names to be plotted below each bar or *group of bars*.
If this argument is omitted, then the names are taken from the names attribute
of height if this is a vector, or the column names if it is a matrix

Thanks for your suggestion. However, I am still not sure how to group all
the entries for "Mon" and include one label. Your solution sort of does
that but it actually does not print the individual values . I would like to
show that there is a lot of variation in C.1 for "Mon".




On Thu, Nov 10, 2011 at 11:32 PM, R. Michael Weylandt <
michael.weylandt@gmail.com> wrote:

> 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.smith@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.
> >
>

	[[alternative HTML version deleted]]

