[R] Beginner question on bar plot

Peter Alspach Peter.Alspach at plantandfood.co.nz
Fri Oct 15 22:54:47 CEST 2010


Tena koe Steven

cutData <- rbind(summary(Acut), summary(Bcut))
barplot(cutData, beside=TRUE)

should get you started.  The challenge, as you identify, is to get the data into the appropriate form and the simple approach I have used may not work for your real data.

HTH ....


Peter Alspach

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of steven mosher
> Sent: Saturday, 16 October 2010 9:01 a.m.
> To: r-help
> Subject: [R] Beginner question on bar plot
> 
> I've read a number of examples on doing a multiple bar plot, but cant
> seem
> to grasp
> how they work or how to get my data into the proper form.
> 
> I have two  variable holding the same factor
> 
> The variables were created using a cut command, The following simulates
> that
> 
> A <- 1:100
> B <- 1:100
>  A[30:60] <- 43
>  Acut <- cut(A,breaks=c(0,10,45,120),labels=c("low","med","high"))
>  Bcut <- cut(B,breaks=c(0,10,45,120),labels=c("low","med","high"))
> 
> What I want to do is create a barplot with  3 groups of side by side
> bars
> 
> group 1, = "low" and the two bars would be the count for Acut, and the
> count
> for Bcut
> group 2 = "med" and the two bars again would be the counts for  this
> factor
> level in Acut and Bcut
> group 3 = high  and like the above two.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

The contents of this e-mail are confidential and may be subject to legal privilege.
 If you are not the intended recipient you must not use, disseminate, distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received this
 e-mail in error, please notify the sender and delete all material pertaining to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.



More information about the R-help mailing list