# BearsCorrSimple Example # Input height and weight of 1985 Chicago Bears players # and convert them to metric bears <- read.fwf("c:/datasets/bears85.txt", header=FALSE, skip=2, widths=c(3, 20, 3, 1, 1, 3, 4), col.names=c("JerseyNumb", "Name", "Pos", "HtFt", "dash", "HtIn", "WtLbs"), strip.white=TRUE) height <- (bears$HtFt + bears$HtIn / 12) * 0.3048; weight <- bears$WtLbs * 0.453592; cat("BearsCorrSimple Example\n\n") cat("Mean of height: ", mean(height), "\n") cat("Mean of weight: ", mean(weight), "\n") cat("SD of height: ", sd(height), "\n") cat("SD of weight: ", sd(weight), "\n") cat("Covariance of height and weight:", cov(height, weight), "\n") cat("Correlation of height and weight:", cor(height, weight), "\n") plot(height, weight, main="Weight vs. Height of 1985 Chicago Bears Players", xlab="Height in Meters", ylab="Weight in Kilos")