mlbbat10: Major League Baseball Player Hitting Statistics for 2010

Description Usage Format Source Examples

Description

Major League Baseball Player Hitting Statistics for 2010.

Usage

1

Format

A tibble with 1199 observations on the following 19 variables.

name

Player name

team

Team abbreviation

position

Player position

game

Number of games

at_bat

Number of at bats

run

Number of runs

hit

Number of hits

double

Number of doubles

triple

Number of triples

home_run

Number of home runs

rbi

Number of runs batted in

total_base

Total bases, computed as 3*HR + 2*3B + 1*2B + H

walk

Number of walks

strike_out

Number of strikeouts

stolen_base

Number of stolen bases

caught_stealing

Number of times caught stealing

obp

On base percentage

slg

Slugging percentage (total_base / at_bat)

bat_avg

Batting average

Source

Data was collected from mlb.com on April 22nd, 2011.

Examples

 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)

OpenIntroStat/openintro-r-package documentation built on Jan. 22, 2020, 3:23 p.m.