Description Usage Arguments Details Value Examples
Apply a linear weights formula to an MLBAM data set
1 | linearWeights(data, type = "xr", ...)
|
data |
An MLBAM data set |
type |
A string representing either "xr27", "woba" |
Applies any of several linear weights formulae to an MLBAM data set
A numeric vector of linear weights values
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ds = getData()
ds$woba = linearWeights(ds, type = "woba")
ds$xr = linearWeights(ds, type = "xr")
leaders = ddply(ds, ~batterId, summarise, Name = batterName[1], PA = sum(isPA)
, WOBA = sum(woba) / sum(isPA == TRUE), XR27 = sum(xr) * 25.5 / sum(isPA & !isHit))
# The top 20
head(leaders[order(leaders$WOBA, decreasing = TRUE),], 20)
# meeting a plate appearance minimum
qualified = subset(leaders, PA > length(unique(ds$gameId)) * 3.1 / 15)
# WOBA leaders
head(qualified[order(qualified$WOBA, decreasing = TRUE),], 20)
# XR27 leaders
head(qualified[order(qualified$XR27, decreasing = TRUE),], 20)
# Compare the two metrics
xyplot(XR27 ~ WOBA, data = qualified)
with(qualified, cor(WOBA, XR27))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.