data <- scan(what = list(fname="",lname="",team="",ab=0,hr=0,salary=0), multi.line=F) Justin Morneau COL 502 17 5.0 Matt Adams STL 527 15 .53 Freddie Freeman ATL 607 18 8.8 Anthony Rizzo CHC 524 32 1.5 Adrian Gonzalez LAD 591 27 21.0 Yonder Alonso SDP 267 7 1.65 Lucas Duda NYM 514 30 4.2 Garrett Jones MIA 496 15 2.75 Ryan Howard PHI 569 23 20.0 data firstbase <- data.frame(data) rm(data) firstbase$hrrate <- firstbase$hr/firstbase$ab firstbase$logithrrate <- log(firstbase$hrrate/(1 - firstbase$hrrate)) firstbase$nohr <- firstbase$ab - firstbase$hr plot(firstbase$salary,firstbase$logithrrate) firstbase.glm <- glm(cbind(hr, nohr) ~ salary, data=firstbase,family=binomial()) summary(firstbase.glm) par(mfrow=c(2,2)) plot(firstbase.glm) par(mfrow=c(1,1))