To do this for the individual plays, you just add a group_by(Player) line after the first mutate() line.

]]>HRdata %

mutate(Age = yearID – birthyear) %>%

select(Player, Age, HR) %>%

mutate(CHR = cumsum(HR))

The graph however seems to perform the cumulative Sums for every players HR totals. Is there a way to unpack the Cumsum function for the individual players? Thank you for the awesome book.

]]>In Chapter 7, when modeling called strike percentage, the book limits the PITCHf/x data to type == “S”, but from the description variable in the first column, it looks like “S” includes strikes of any kind. Rather than “S” and “X” being “called strikes” and “strikes” respectively as noted in the book, I’m pretty sure they stand for “strikes” and “balls in play.”

Thanks

]]>