# generate descriptive stats and graphs on weight, height # get basic histogram of weight hist(vecheight, main="UM Football WEIGHT Distribution", xlab="pounds", ylab="frequency") # generate relevant summary statistics summary(vecweight) cat("std dev=",sd(vecweight),"\n") # get weight as relative frequency on histogram wt <- vecweight/length(vecweight) hist(wt, main="UM Football WEIGHT Distribution", xlab="pounds", ylab="rel frequency") lines(density(wt)) # this gets a profile line on histogram # generate another displays of WEIGHT cat("TEAM WEIGHTS", stem(vecweight), "\n") # generate another display boxplot(vecweight, main="Team WEIGHT", ylab="inches") # generate another f1 <- fivenum(wt) cat("five number summary =", f1, "\n") # compare WEIGHT and HEIGHT # first produce a scatterplot plot(vecheight, vecweight, main="Scatterplot of WEIGHT vs HEIGHT") # now do a linear regression model with the data and store in variable line1 # also print out r line1 <- lm(vecweight ~ vecheight) line1 cat("r=", cor(vecweight,vecheight), "\n") # plot line of best fit on scatterplot plot(vecheight, vecweight, main="Scatterplot of WEIGHT vs HEIGHT", xlab="inches", ylab="pounds") abline(line1) # do scatterplot labeled by position, using first letter plot(vecweight, vecheight, pch=as.character(vecposition), main="scatterplot of WEIGHT on HEIGHT, Coded with letters") # do scatterplot labeled by position, using symbol plot(vecweight, vecheight, pch=as.numeric(vecposition), main="Scatterplot of WEIGHT on HEIGHT, Coded with Symbols", xlab=") # do residual plot res1 <- resid(line1) plot(vecheight, res1, main="Residual Plot-WEIGHT vs HEIGHT", xlab="pounds", ylab="residuals") abline(0,0) # plot a line with intercept=0 followed by slope=0