# Boxplots Example -- Create a variety of boxplots # under a variety of conditions. # Read data from UCLA website. hsb2 <- read.table('http://www.ats.ucla.edu/stat/r/modules/hsb2.csv', header=T, sep=",") attach(hsb2) # Send graphs to file. pdf("boxplots.pdf") # Create boxplots. boxplot(write, main="Boxplots Example: Boxplot 1") boxplot(write, xlab="Writing Score", boxwex=.4, col="lightblue", main="Boxplots Example: Boxplot 2") boxplot(write ~ ses, main="Boxplots Example: Boxplot 3") seslab <- as.vector(c("low","medium", "high")) sesf <- factor(ses, label=seslab) boxplot(write ~ sesf, xlab="write by ses", main="Boxplots Example: Boxplot 4") boxplot(write ~ sesf, xlab="write by ses", boxwex=.2, notch = TRUE, col = "lightblue", main="Boxplots Example: Boxplot 5") # Use two factors boxplot(write ~ female + ses, xlab="write by female and ses", boxwex=0.2) dev.off( )