diff --git a/scripts/Chap8.trajectories.R b/scripts/Chap8.trajectories.R index 0d1d203..5a87263 100644 --- a/scripts/Chap8.trajectories.R +++ b/scripts/Chap8.trajectories.R @@ -33,7 +33,7 @@ get.stats <- function(player.id){ d$Age <- d$yearID - byear d$SLG <- with(d, (H - X2B - X3B - HR + 2 * X2B + 3 * X3B + 4 * HR) / AB) - d$OBP <- with(d, (H + BB) / (H + AB + BB + SF)) + d$OBP <- with(d, (H + BB + HBP) / (AB + BB + SF + HBP)) # HBP are part of OBP formula, H should not be in denominator. d$OPS <- with(d, SLG + OBP) d } @@ -298,4 +298,4 @@ ggplot(dnew, aes(Age, OPS)) + geom_point(size=4) + stat_smooth(method="lm", se=FALSE, size=1.5, formula=y ~ poly(x, 2, raw=TRUE)) + theme_bw() -################################################################ \ No newline at end of file +################################################################