# R Script for Box-and-Whisker Plot Using Iris # Erin Norton, Stephen Savoia & Elizabeth Hayden # Simple Box-and-Whisker Plot iris attach(iris) names(iris) Species=factor(Species) plot(Species, Sepal.Length) # To Verify Minimum, Maximum, Mean, Standard Deviation, and # Variance Values Obtained in Graph xbar=tapply(Sepal.Length,Species,mean) n=tapply(Sepal.Length,Species,length) mn=tapply(Sepal.Length,Species,min) mx=tapply(Sepal.Length,Species,max) s=tapply(Sepal.Length,Species,sd) v=tapply(Sepal.Length,Species,var) cbind("NUMBER"=n,"MINIMUM"=mn,"MAXIMUM"=mx,"MEAN"=xbar,"STD DEV"=s,"VARIANCE"=v) # To Verify Quartile Values x=seq(4.3,5.8,0.1) mu=5.006 sigma=0.3524897 SL.setosa=Sepal.Length[Species=="setosa"] summary(SL.setosa) # Labeling Box-and-Whisker Plot While Graphing plot(Species,Sepal.Length,ylab="length",xlab="species",main="Sepal.Length") # Labeling Box-and-Whisker Plot After Graph is Generated plot(Species, Sepal.Length) title(main="Sepal.Length") title(xlab="species") title(ylab="length") # Adding Colors to Box-and-Whisker Plots plot(Species,Sepal.Length,ylab="length",xlab="species",main="Sepal.Length",col="green") # To Add Colors to Specific Boxes plot(Species,Sepal.Length,ylab="length",xlab="species",main="Sepal.Length", col=c("pink","blue","green")) # Representing Confidence Intervals plot(Species,Sepal.Length,main="Sepal Length Box and Whisker Plot",col=c("red","blue","green"),notch=T)