library(plyr) library(ggplot2)
CFB <- read.csv(“https://raw.githubusercontent.com/danielhong98/MSDA-Fall/3da951541fa121fb59a9cf3f8e7fe01ace774dc8/cfb20092013.csv”, header = T)
attach(CFB)
X = na.omit(CFB\(Margin) Y = na.omit(CFB\)Distance)
summary(X) summary(Y) qplot(X, geom=‘histogram’) qplot(Y, geom=‘histogram’)
Median <- as.factor(ifelse(Distance <= 520.7, “0-520.7”, “520.7+”))
CFB <- data.frame(CFB, Median)
round(tapply(X, Median, mean),2)
ggplot(CFB, aes(X, color=Median)) + geom_freqpoly(binwidth=0.5, origin=-5.75)
plot(Median, X)
t.test(X ~ Median, var.equal=T)
model1 <- lm(X ~ Y) summary(model1) confint(model1)
ggplot(CFB, aes(X, Y)) + geom_smooth(method=“lm”) + scale_x_continuous(breaks=c(0,50,100,150,200,250,300)) + labs(Y=“Distance (Miles)”, X=“Margin (Points)”, title=“Distance (Miles) and Margin of Victory by Home Team”)
ggplot(CFB, aes(X,Y)) + geom_smooth(method=“lm”) + geom_point() + labs(Y=“Distance (Miles)”, X=“Margin (Goals)”, title=“Distance (Miles) and Margin of Victory by Home Team”)