0

I am working on a baseball related project and I took the averages of the statistic wOBA for each different player from pitch by pitch data. I wanted to add those averages to my original pitch by pitch data frame, but the only problem is that there are multiples of each player ID on the first data frame, so I can't figure out how I am able to attach the averages to each ID. Here's an example of what I'm looking at:

Averages data frame:

        batterID  wOBA
  {1}   84621     .321
  {2}   95480     .296

Pitch by pitch data frame:

        batterID  AB  wOBA average
  {1}   84621     1   (put his average wOBA here)
  {2}   84621     2   (put his average wOBA here)
  {3}   84621     3   (put his average wOBA here)
  {4}   95480     1   (put his average wOBA here)
  {5}   95480     2   (put his average wOBA here)
  {6}   95480     3   (put his average wOBA here)

I've tried mutating it, but that didn't work as the data frames have different amounts of columns. What could I do here?

kaifranke
  • 23
  • 4

0 Answers0