Data series – how to pull out specific data relating to times within a time series

I have some speed data which relates to time (running clock). I am trying to separate the last 15 minutes of the data series to run some simple descriptive statistics on (rolling_averages) etc

My code is below for the entire data series - I calculated rolling averages for 1,3 and 5 minute time epochs. I need to run the same but only on the last 15 minutes of the match.

However, I don't know where to start. Any guidance would be greatly appreciated!

Here is what I have so far:

rolling_averages <- john %>%
  group_by(Game, Half) %>%
  # create new columns showing the rolling averages over 1, 3, and 5 minutes
  mutate(`1min` = rollmean(`Speed..m.s.`, 600, fill = NA, align = "right") * 60,
         `3min` = rollmean(`Speed..m.s.`, 1800, fill = NA, align = "right") * 60,
         `5min` = rollmean(`Speed..m.s.`, 3000, fill = NA, align = "right") * 60) %>%
  # remove all columns except these ones
  select(Time, Game, Half, `1min`, `3min`, `5min`) %>%

Read more here:

Content Attribution

This content was originally published by Rhys-Morris at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: