[R] barplot

Achim Zeileis zeileis at ci.tuwien.ac.at
Sat May 11 18:51:04 CEST 2002


syed gillani wrote:
> 
> Hi all,
> 
> I have read in an epiinfo rec file with more than 100 variables and about
> 5500 rows. Among the variables are the following three: OB, a 0,1 coded
> variable indicating the presence of obesity, GEN, a 1,2 coded variable
> indicating gender and AGEGP, a variable  with values ranging from 1 to 11,
> indicating agegroups.
> How could I make a barplot showing male and female obese persons by age
> groups?

I guess the simplest way is to first create a table with the information
you want, probably something like:
R> mytable <- xtabs(~ GEN + AGEGP, data = mydata, subset = OB == 1)
R> barplot(mytable)
If you code the variables as factors with proper labels then the labels
of the barplot will also be done automatically.
Z

> Thanks
> Basharat
> syed at saudionline.com.sa
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list