Re: [R] Stacked barchart in ggplot (or other library)

2012-01-20 Thread Justin Haynes
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  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]]
>
> __
> 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]]

__
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.


Re: [R] Stacked barchart in ggplot (or other library)

2012-01-20 Thread Jean V Adams
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]]

__
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] Stacked barchart in ggplot (or other library)

2012-01-20 Thread Bart6114
Hey,

I want to create a stacked barchart in R for the following dataset
(http://pastebin.com/pyHUNgr2):

#   usage   capacitydiff
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!  

--
View this message in context: 
http://r.789695.n4.nabble.com/Stacked-barchart-in-ggplot-or-other-library-tp4313455p4313455.html
Sent from the R help mailing list archive at Nabble.com.

__
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.