############################################################################ # NAME: Chris Bilder # # DATE: 9-19-05 # # PURPOSE: Do the histogram trellis plot using standardized data within # # a variable specification only (not by shelf) # # # # NOTES: 1) # # # ############################################################################ #R IS CASE SENSITIVE #Read in the data cereal<-read.table(file = "C:\\chris\\UNL\\STAT873\\Chapter 3\\cereal.txt", header=TRUE) library(lattice) trellis.par.set(col.whitebg()) #Set color theme for plots #New way using the scale function. temp<-data.frame(sugar2 = cereal$sugar, fat2 = cereal$fat, sodium2 = cereal$sodium) stand.cereal<-scale(temp) cereal2<-data.frame(cereal, stand.cereal) sugar<-data.frame(ID = cereal2$ID, Shelf = cereal2$Shelf, value = cereal2$sugar2, variable = "Sugar") fat<-data.frame(ID = cereal2$ID, Shelf = cereal2$Shelf, value = cereal2$fat2, variable = "Fat") sodium<-data.frame(ID = cereal2$ID, Shelf = cereal2$Shelf, value = cereal2$sodium2, variable = "Sodium") all.cereal<-rbind.data.frame(sugar, fat, sodium) win.graph(width = 7, height = 7, pointsize = 9) histogram(formula = ~ value | variable + factor(Shelf), data = all.cereal, type = "percent", layout = c(3,4), xlab = "Standardized value", as.table=TRUE)