Re: [R] barplot for a categorial variable

From: <Bill.Venables_at_csiro.au>
Date: Thu, 31 Jul 2008 10:18:38 +1000

Try

with(yourData, barplot(table(Type)))

or, if you really want percentages something like

with(yourData, barplot(table(Type)/length(Type)*100, ylab = "Percentage"))

(BTW, it would be nice to know who you are.)

Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA

Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile:                         +61 4 8819 4402
Home Phone:                     +61 7 3286 7700
mailto:Bill.Venables_at_csiro.au
http://www.cmis.csiro.au/bill.venables/

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of kayj
Sent: Thursday, 31 July 2008 8:14 AM
To: r-help_at_r-project.org
Subject: [R] barplot for a categorial variable

Hi all,

I have data with several columns and rows. one of the column is "Type" that
can be either A, B, C or D.
I need to plot the "Type" variable as a bar plot where the x axis is the type A, B ,C or D and the y axis shows the percentage. I was not able to get
a bar plot. it seems that I need to convert the categorial variable into numeric values. Is there any way how to get the bar plot without doing the
conversion,

Thanks

-- 
View this message in context:
http://www.nabble.com/barplot-for-a-categorial-variable-tp18743744p18743
744.html
Sent from the R help mailing list archive at Nabble.com.


______________________________________________
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.
______________________________________________
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.
Received on Thu 31 Jul 2008 - 00:24:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 31 Jul 2008 - 00:33:00 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive