Re: [R] Bar Chart

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Thu, 24 Mar 2011 18:01:23 +1100

On 03/24/2011 03:26 AM, blutack wrote:
> How do you do a bar chart of 2 vectors?
> I have one vector which has 10 numbers, and another which has 10 names.
> The numbers are the frequency of the corresponding name, but when I do a bar
> chart it says that there is no height. Thanks.
>
Hi blutack (any relation to Bluto?),
My guess is that you want the frequencies as the heights of the bars and the names as the labels of the bars:

heights<-sample(10:30,10)
bar_names<-c("Oliver","Petroushka","Queequag","Rumplestiltskin",   "Sinbad","Tycho","Uranus","Vesalius","Wojtec","Xavier") barplot(heights,names.arg=bar_names)

Whoops! Lost some of the labels:

library(plotrix)
barp(heights,names.arg=bar_names,staxx=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. Received on Thu 24 Mar 2011 - 07:06:02 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 24 Mar 2011 - 08:40:24 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