##--------------------------------- ## NFL Salaries ##--------------------------------- # Import NFLsalary data salary = read.csv("http://faculty.chicagobooth.edu/nicholas.polson/teaching/41000/NFLsalary.csv", header = TRUE) # attach the dataset attach(salary) # Plot a boxplot to compare salaries of the NFC to AFC. plot(Conf, Salary, main="Team Salary by Conference", xlab="Conference", ylab="Salary ($1,000s)") # Dummy coding (dummy code the "Conf" variable into NFC = 1 and AFC = 0) dConf = as.numeric(Conf) - 1 # Routine analysis mean(dConf) sd(dConf) cor(dConf, Salary) # Linear regression wit a dummy variable model = lm(Salary ~ QB + dConf) # model = lm(Salary ~ QB + Conf) #produces the same regression result. summary(model) # detach the dataset detach(salary)