[R] Trying to get values to display on horizontal barchart

From: gblevins <gblevins_at_mn.rr.com>
Date: Mon 15 May 2006 - 17:28:36 EST


Hello,
R 2.3.0
Windows XP

I have spent quite a bit of time trying to resolve my problem below, which included a R site search.

The "vertical bars" syntax below produces a vertical bar chart with the values displayed above each bar. I want to cast this graphic horizontally, but I have not been able to arrive at a suitable outcome. The best I have been able to do, using the second block of syntax below, is to get the values to display along the right edge of the horizontal graph whereas my goal is to have them displayed just off the ends of each horizontal bar, as they are on the veritical graph.

I was hoping someone could provide me with direction or a solution to this problem.

#Vertical bars syntax:

math.bar <- c(53,31,55,28,55,100)
names(math.bar) <- c('Grade \n 3','Grade \n 4','Grade \n 5','Grade \n 6','Grade \n 7','Grade \n 8') o <- rev(order(math.bar))
math.bar <- math.bar[o]
par(ps=10)
math.barplot <- barplot(math.bar, main = list("Death Rates in Virginia", font = 1), col=c('darkblue'), names=c('Grade \n 3','Grade \n 4','Grade \n 5','Grade \n 6','Grade \n 7','Grade \n 8'), ylim=c(0,100), ylab="Percentage", xlab="Grade Level") text(math.barplot, math.bar+5, math.bar, xpd = TRUE)

#Horizontal bars syntax:

par(mar=c(5, 9, 5, 2))
math.bar <- c(53,31,55,28,55,100)
names(math.bar) <- c('Grade 3','Grade 4','Grade 5','Grade 6','Grade 7','Grade 8') o <- rev(order(math.bar))
math.bar <- math.bar[o]
par(ps=10)
math.barplot <- barplot(math.bar, horiz=T, las=2, main = list("Death Rates in Virginia", font=1), col=c('darkblue'), xlim=c(0,100), ylab="Grade Level", xlab="Percent") mtext(side=4, at=math.barplot, math.bar, las=2) Thank you,

Greg Blevins
The Market Solutions Group

        [[alternative HTML version deleted]]



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 Received on Mon May 15 17:32:40 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 Tue 16 May 2006 - 00:10:06 EST.

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