Created
March 29, 2012 18:16
-
-
Save alexstorer/2241411 to your computer and use it in GitHub Desktop.
Titled Bar Plots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hsb2 <- read.table('http://www.ats.ucla.edu/stat/R/faq/hsb2.csv', header=T, sep=",") | |
attach(hsb2) | |
sesmeans <- tapply(math, ses, mean) | |
femaleses = tapply(math, list(as.factor(ses), as.factor(female)), mean) | |
bp <- barplot(femaleses, beside = TRUE, main = "Math by SES and gender", | |
col = c("lightblue", "mistyrose", "lavender"), | |
xlab = "Gender", names = c("Male", "Female"), | |
ylab = "Mean Math Score", legend = c("Low", "Medium", "High"), | |
args.legend = list(title = "SES", x = "topright", cex = .7), ylim = c(0, 90)) | |
text(bp, femaleses, c("dogs","cats","fish","emus","gnus","vultures"),cex=1,pos=3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment