mlb_players_18 | R Documentation |
Batter statistics for 2018 Major League Baseball season.
mlb_players_18
A data frame with 1270 observations on the following 19 variables.
Player name
Team abbreviation
Position abbreviation: 1B
= first base,
2B
= second base, 3B
= third base, C
= catcher,
CF
= center field (outfield), DH
= designated hitter,
LF
= left field (outfield), P
= pitcher,
RF
= right field (outfield), SS
= shortstop.
Number of games played.
At bats.
Runs.
Hits.
Doubles.
Triples.
Home runs.
Runs batted in.
Walks.
Strike outs.
Stolen bases.
Number of times caught stealing a base.
Batting average.
On-base percentage.
Slugging percentage.
On-base percentage plus slugging percentage.
mlbbat10
, mlb
d <- subset(mlb_players_18, !position %in% c("P", "DH") & AB >= 100)
dim(d)
# _____ Per Position, No Further Grouping _____ #
plot(d$OBP ~ as.factor(d$position))
model <- lm(OBP ~ as.factor(position), d)
summary(model)
anova(model)
# _____ Simplified Analysis, Fewer Positions _____ #
pos <- list(
c("LF", "CF", "RF"),
c("1B", "2B", "3B", "SS"),
"C"
)
POS <- c("OF", "IF", "C")
table(d$position)
# _____ 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$OBP[these])
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.