# Box & Whisker plot Example # Uses finished water fluoride levels shown from ProcessTrends.com site # R script develeloped by D Kelly O'Day for information purposes only. library(lattice) link <- c("C:\\R_Home\\Charts & Graphs Blog\\Box_Whisker\\fluoride.csv") my_Data <- read.table(link, skip = 0, sep = ",", dec=".", row.names = NULL, header = FALSE, colClasses = c("numeric", "factor", "NULL", "numeric"), comment.char = "#", na.strings = c("*", "-",-99.9, -999.9), col.names = c("week", "week_dt", "ignore", "fluoride")) attach(my_Data) # reorder week_dt factor to sort by week number, not alphabetically on week_dt by_week <- with(my_Data,(reorder(week_dt, week, mean))) ###### boxplot for each week ########################################### trellis.par.set(box.rectangle = list(col="grey"), box.dot =list(col = "grey", pch = 16, cex = 0.5), box.umbrella= list(col = "grey", lty= "solid"), plot.symbol = list(col = "red", pch = 16 , cex = .5 )) xyplot(fluoride ~ by_week, my_Data, main = "Box & Whisker Plot: Weekly Results \n Fluoride Concentrations \n (10/1/02 - 1/20/03)", par.settings=list(axis.text=list(cex=0.9), fontsize=list(text=9)), panel = panel.bwplot, horizontal = FALSE, ylab = "Fluoride Concentration - mg/l", xlab = "Week Begining " , box.ratio =0.5 )