# ------------------------------------------------ # Program: Univariate2.S # Author: Steven M. Boker # Date: Tue Sep 21 13:03:58 EST 2004 # # Provides examples of the use of boxplots and # histograms. # # ------------------------------------------------ # ------------------------------------------------ # Create two data vectors and a dataframe of them. X <- c(1,2,3,4,5,6,7,8,9,10) Y <- c(2,4,3,5,4,6,5,7,6,8) Test2 <- data.frame(X=X, Y=Y) Test2 summary(Test2) # ------------------------------------------------ # Scatter plot. graphsheet(height=6.4,width=6.4) plot(X, Y) # ------------------------------------------------ # Scatter plot with fixed axis scales. graphsheet(height=6.4,width=6.4) plot(c(0,10),c(0,10),main = "Test 2", ylab = "Y", xlab = "X", type="n") lines(X, Y, type="p") # ------------------------------------------------ # Read the iris data. iris <- data.frame(read.table("iris.dat", header=T)) summary(iris) # ------------------------------------------------ # Box plot of Iris sepal length. graphsheet(height=6.4,width=6.4) boxplot(iris$sepal.length, ylab="sepal.length") # ------------------------------------------------ # Multiple boxplots on the same page. graphsheet(height=6.4,width=6.4) par(mfrow=c(2,2)) boxplot(iris$sepal.length, ylab="sepal.length") boxplot(iris$sepal.width, ylab="sepal.width") boxplot(iris$petal.length, ylab="petal.length") boxplot(iris$petal.width, ylab="petal.width") # ------------------------------------------------ # Histogram of sepal length. graphsheet(height=6.4,width=7.5) hist(iris$sepal.length, nclass=10, xlab="sepal.length")