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.
Here is what I have so far:
library(dplyr)
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
# remove all columns except these ones
select(Time, Game, Half, `1min`, `3min`, `5min`) %>%
Player.Display.Name Time Speed..m.s. Game Half
S 00:33:17 2.430557 A 1
2 S 00:33:17 2.488891 A 1
3 S 00:33:17 2.580558 A 1
4 S 00:33:17 2.530558 A 1
5 S 00:33:17 2.488891 A 1
6 S 00:33:17 2.430557 A 1
>