Calculating the rolling average, I have tried the following:
mutate(mean10min = slide_dbl('Cleaned BPM', mean, na.rm = TRUE, .before = 3, .after = 0, .complete = TRUE))
and
mutate(rolling_avg = rollmean('Cleaned BPM', k=3, fill=NA, align='right'))
However in both cases, the new column is filled with only NAs. My data is numeric. What is the issue and how do I solve it?
The data is part of a larger dataset, imported by read_excel(). Here's the relevant extract:
I have tried rolling_avg() on simple data, and there it works, thus there must be something wrong with the format of my 'Cleaned BPM', I assume.


Cleaned BPMrequires backticks:(See here re non-syntactic names.)
Created on 2024-03-12 with reprex v2.1.0