[R] Want to create a histogram

John Kane jrkrideau at inbox.com
Sun Oct 20 13:35:57 CEST 2013

I  don't think you do. I think that you are confusing a histogram and a bar chart.  With only five data points and five categories you have data for a barplot.

I see Jim has provided one approach 

Another, using the ggplot2 package (which you will probably have to install is :

# to install ggplot2 package

dat1  <- data.frame(  aa  =  c("very bad", "bad", "fair", "good", "very good"),
bb = c(159, 374, 3765, 11388, 6708))

ggplot(dat1, aes(aa, bb)) + geom_bar(stat="identity")

John Kane
Kingston ON Canada

> -----Original Message-----
> From: kannan at iitb.ac.in
> Sent: Sun, 20 Oct 2013 00:54:39 +0000
> To: r-help at r-project.org
> Subject: [R] Want to create a histogram
> Dear All,
> For a report that I am writing, I need to create a histogram plot with
> x-axis fixed as very bad, bad, fair, good and very good - i.e. the order
> not changed.  Can someone give me an example?  For sample purposes, I am
> giving the following data: 159, 374, 3765, 11388, 6708.  Thanks,
> Kannan
> ______________________________________________
> 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.

FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!

More information about the R-help mailing list