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.
Player name
Team abbreviation
Player position
Number of games
Number of at bats
Number of runs
Number of hits
Number of doubles
Number of triples
Number of home runs
Number of runs batted in
Total bases, computed as 3*HR + 2*3B + 1*2B + H
Number of walks
Number of strikeouts
Number of stolen bases
Number of times caught stealing
On base percentage
Slugging percentage (total_base / at_bat)
Batting average
https://www.mlb.com, retrieved 2011-04-22.
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 53 54 | ## Not run:
d <- mlbbat10[mlbbat10$at_bat > 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$position %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)))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.