Description Usage Format Source Examples
Major League Baseball Player Hitting Statistics for 2010.
1 |
A data frame with 1199 observations on the following 19 variables.
namePlayer name
teamTeam abbreviation
positionPlayer position
GNumber of games
ABNumber of at bats
RNumber of runs
HNumber of hits
2BNumber of doubles
3BNumber of triples
HRNumber of home runs
RBINumber of runs batted in
TBTotal bases, computed as 3*HR + 2*3B + 1*2B + H
BBNumber of walks
SONumber of strikeouts
SBNumber of stolen bases
CSNumber of times caught stealing
OBPOn base percentage
SLGSlugging percentage (TB / AB)
AVGBatting average
Data was collected from MLB.com on April 22nd, 2011.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | data(mlbBat10)
d <- mlbBat10[mlbBat10$AB > 200,]
pos <- list(c("OF"), c("1B", "2B", "3B", "SS"), "DH", "C")
POS <- c("OF", "IF", "DH", "C")
#=====> On-base Percentage Across Positions <=====#
out <- c()
gp <- c()
for(i in 1:length(pos)){
these <- which(d$pos %in% pos[[i]])
out <- c(out, d[these,"OBP"])
gp <- c(gp, rep(POS[i], length(these)))
}
plot(out ~ as.factor(gp))
summary(lm(out ~ as.factor(gp)))
anova(lm(out ~ as.factor(gp)))
#=====> Batting Average Across Positions <=====#
out <- c()
gp <- c()
for(i in 1:length(pos)){
these <- which(d$pos %in% pos[[i]])
out <- c(out, d[these,"AVG"])
gp <- c(gp, rep(POS[i], length(these)))
}
plot(out ~ as.factor(gp))
summary(lm(out ~ as.factor(gp)))
anova(lm(out ~ as.factor(gp)))
#=====> Home Runs Across Positions <=====#
out <- c()
gp <- c()
for(i in 1:length(pos)){
these <- which(d$pos %in% pos[[i]])
out <- c(out, d[these,"HR"])
gp <- c(gp, rep(POS[i], length(these)))
}
plot(out ~ as.factor(gp))
summary(lm(out ~ as.factor(gp)))
anova(lm(out ~ as.factor(gp)))
#=====> Runs Batted In Across Positions <=====#
out <- c()
gp <- c()
for(i in 1:length(pos)){
these <- which(d$pos %in% pos[[i]])
out <- c(out, d[these,"RBI"])
gp <- c(gp, rep(POS[i], length(these)))
}
plot(out ~ as.factor(gp))
summary(lm(out ~ as.factor(gp)))
anova(lm(out ~ as.factor(gp)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.