[R] How to plot grouped bar plot in R?
David L Carlson
dcarlson at tamu.edu
Fri Jun 22 16:16:37 CEST 2012
This will get it assuming the data.frame is arranged like this
DatFile <- read.table(text="Name x1 x2
Alpha 0 0.625
Beta 1 0.107143
Gama 2 0.910714
Delta 0 0
zeta 0 0
eta 0 0.089286",
sep="", header=TRUE)
rownames(DatFile) <- DatFile$Name
barplot(t(DatFile[,2:3]), beside=TRUE, horiz=TRUE)
----------------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77843-4352
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Jim Lemon
> Sent: Friday, June 22, 2012 6:46 AM
> To: Manish Gupta
> Cc: r-help at r-project.org
> Subject: Re: [R] How to plot grouped bar plot in R?
>
> On 06/22/2012 07:35 PM, Manish Gupta wrote:
> > HI,
> >
> > I have one input file
> > Alpha 0 0.625
> > Beta 1 0.107143
> > Gama 2 0.910714
> > Delta 0 0
> > zeta 0 0
> > eta 0 0.089286
> >
> > I want to to plot bar plot like below
> >
> > http://r.789695.n4.nabble.com/file/n4634182/Screenshot.png
> >
> > I can plot if i have input file in transpose format but how can i do
> this
> > in R using above input file.
> >
> Hi Manish,
> Don't you ever read the help pages?
>
> barplot(cbind(Alpha,Beta,Gama,Delta,zeta,eta),beside=TRUE,horiz=TRUE)
>
> Jim
>
> ______________________________________________
> R-help at 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.
More information about the R-help
mailing list