#Sample Boxplot Script iris attach(iris) SL=Sepal.Length plot(Species,SL) #Sample Boxplot Script (w/ labeled axes and title) attach(iris) plot(Species, Sepal.Length,xlab="Species",ylab="Sepal Length") title("Sepal Length") #Adding colors: plot(Species, Sepal.Length,col=(("green","purple","blue")),main="Sepal Length",xlab="Species",ylab="Sepal Length") #Checking for accuracy #To save on typing, assign shorter names: SL=Sepal.Length SL.setosa=Sepal.Length[Species=="setosa"] SL.versicolor=Sepal.Length[Species=="versicolor"] SL.virginica=Sepal.Length[Species=="virginica"] quantile(SL) quantile(SL.setosa) quantile(SL.versicolor) quantile(SL.virginica) #You can also use the following functions for minimum value, median, and maximum value: min(SL.setosa) median(SL.setosa) max(SL.setosa) #Notched Boxplot (with axes labeled and title included) boxplot(Sepal.Length~Species,notch=TRUE,xlab="Species",ylab="Sepal Length") title("Sepal Length") #Adding colors: boxplot(Sepal.Length~Species, notch=TRUE, col=(c("gold","darkgreen","blue")),main="Sepal Length", xlab="Species",ylab="Sepal Length") #For the boxplot to be oriented horizontally: plot(Species, Sepal.Length,xlab="Sepal Length",ylab="Species", horizontal=TRUE) #In order to use the violinplot() function you have to install the package "UsingR" ?violinplot violinplot(Sepal.Length~Species, col="brown") #To add a border color: violinplot(Sepal.Length~Species, col="yellow",border="purple") #Boxplot with varied widths Install package "lattice" and then load package: singer attach(singer) boxplot(height~voice.part) boxplot(height~voice.part,varwidth=TRUE)