to use ggplot:
dat<-data.frame(num=1:3,usage=c(4,2,5),cap=c(10,20,10),diff=c(6,18,5))
dat.melt<-melt(dat,id.var=c('num','cap'))
ggplot(dat.melt)+geom_bar(aes(x=num,y=value,fill=variable),stat='identity')
On Fri, Jan 20, 2012 at 12:30 PM, Jean V Adams <[email protected]> wrote:
> Bart6114 wrote on 01/20/2012 08:54:39 AM:
>
> > Hey,
> >
> > I want to create a stacked barchart in R for the following dataset
> > (http://pastebin.com/pyHUNgr2):
> >
> > # usage capacity diff
> > 1 4 10 6
> > 2 2 20 18
> > 3 5 10 5
> >
> > The stacked barchart should, in one plot show each line of the dataset
> as a
> > stacked bar using data from 'usage' and 'diff' to create the stacked
> bar.
> >
> > I can't find a good example of how to do this on the ggplot2 site.
> >
> > Thanks in advance!
>
>
> See the help on barplot:
> ?barplot
>
> For example:
>
> df <- data.frame(usage=c(4, 2, 5), capacity=c(10, 20, 10), diff=c(6, 18,
> 5))
> barplot(t(as.matrix(df[, 1:2])))
>
> Jean
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] 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]]
______________________________________________
[email protected] 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.