Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 206278

Calculate centered moving average of dataset, ignoring NAs, output same length as input?

$
0
0

Ultimately I want to create a 15 hour moving average of my dataset. The data I am working with has a date and time for every 15 minutes. I need the window centered (so 30 time steps before/after the row I'm looking at). I also need to be able to link the moving average data back in with my datetime data, so I need it to be the same length as my original dataframe.

I have tried this using a number of functions (movag, MAVE, rollmean, ...), but have not been able to find the correct combination to do both a centered average and pad the result with the appropriate number of NA results.


Viewing all articles
Browse latest Browse all 206278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>