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.
name
Player name
team
Team abbreviation
position
Player position
G
Number of games
AB
Number of at bats
R
Number of runs
H
Number of hits
2B
Number of doubles
3B
Number of triples
HR
Number of home runs
RBI
Number of runs batted in
TB
Total bases, computed as 3*HR + 2*3B + 1*2B + H
BB
Number of walks
SO
Number of strikeouts
SB
Number of stolen bases
CS
Number of times caught stealing
OBP
On base percentage
SLG
Slugging percentage (TB / AB)
AVG
Batting 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.