| battingStats | R Documentation |
The Batting does not contain batting statistics derived from those
present in the data.frame. This function calculates
batting average (BA),
plate appearances (PA),
total bases (TB),
slugging percentage (SlugPct),
on-base percentage (OBP),
on-base percentage + slugging (OPS), and
batting average on balls in play (BABIP)
for each record in a Batting-like data.frame.
battingStats(data = Lahman::Batting,
idvars = c("playerID", "yearID", "stint", "teamID", "lgID"),
cbind = TRUE)
data |
input data, typically |
idvars |
ID variables to include in the output data.frame |
cbind |
If |
Standard calculations, e.g., BA <- H/AB are problematic because of the
presence of NAs and zeros. This function tries to deal with those
problems.
A data.frame with all the observations in data.
If cbind==FALSE, only the idvars and the calculated variables are returned.
Michael Friendly, Dennis Murphy
Batting, BattingPost
bstats <- battingStats()
str(bstats)
bstats <- battingStats(cbind=FALSE)
str(bstats)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.