[R] Bargraphs by a Newbie

From: David Arnold <dwarnold45_at_cox.net>
Date: Sun 10 Sep 2006 - 20:58:57 GMT


All,

I have this data saved in the file bargraph.dat:

Month Births Deaths
January 305 218
February 289 191
March 313 198
April 342 189
May 311 195
June 324 182
July 345 192
August 341 178
September 353 176
October 329 193
November 304 189
December 324 192

I start an R session, change to the directory containin bargraph.dat, and:

> bd=read.table("bargraph.dat",header=T)
> bd

        Month Births Deaths
1 January 305 218
2 February 289 191

3      March    313    198
4      April    342    189
5        May    311    195
6       June    324    182
7       July    345    192
8     August    341    178

9 September 353 176
10 October 329 193
11 November 304 189
12 December 324 192

Seems successful. But when I try:

> attach(bd)
> barplot(Births,names.arg=Month)

I get a barplot with labels on the bottom that are the "numbers" of the months, and they are unordered. Can the above code be used to get the actual names of the months?

I did get this to work.

> b=Births
> names(b)=Month
> barplot(b)

This does show the names of the months below each bar. However, because the names are so long, not all show up unless I manually enlarge the size of the window with the mouse. This raises a second question. How can I rotate the names of the months in this last graph 90 degrees?

Thanks.



R-help@stat.math.ethz.ch 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 Mon Sep 11 07:06:13 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 11 Sep 2006 - 12:30:04 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.