I have a large dataframe with a time series that has a lot of noise. There are 424506 observations. I am trying to smooth the noise using the moving-average method in the function smooth_data().
My data:
head(hydro)
datetime FOR_cm FOR_m3s COM_cm COM_m3s URB_cm URB_m3s avgrain_cm FOR_bf FOR_qf COM_bf
1 2020-03-02 16:12:00 6.6 0.06946219 22.6 0.3398110 33.4 0.017 NA 0.03982154 0.03946884 0.2593084
2 2020-03-02 16:13:00 6.6 0.06946219 22.6 0.3398110 33.4 0.017 NA 0.03394023 0.03552196 0.1904826
3 2020-03-02 16:14:00 6.5 0.06705898 22.8 0.3413505 33.4 0.017 NA 0.03411184 0.03294715 0.1912330
4 2020-03-02 16:15:00 6.5 0.06705898 22.5 0.3390439 33.4 0.017 0 0.03458631 0.03247267 0.1933325
5 2020-03-02 16:16:00 6.5 0.06705898 22.5 0.3390439 33.5 0.017 NA 0.03529537 0.03176362 0.1964959
6 2020-03-02 16:17:00 6.5 0.06705898 22.4 0.3382786 33.7 0.017 NA 0.03618733 0.03087165 0.2004819
COM_qf URB_bf URB_qf
1 0.1659205 0.01416667 -0.001680193
2 0.1493285 0.01453401 0.002465990
3 0.1501174 0.01478061 0.002219391
4 0.1457114 0.01500255 0.001997452
5 0.1425480 0.01520229 0.001797707
6 0.1377967 0.01538206 0.001617936
An example of the plot of a series with acceptable noise (gold) and the series I am trying to smooth (gray) enter image description here
I am running:
MJP_smooth <- smooth_data(x= hydro$datetime, y= hydro$URB_m3s, sm_method = "moving-average", window_width_n = 5)
And I receive these errors:
Error in FUN(newX[, i], ...) : unused argument (simplify = FALSE)
In addition: Warning message:
In check_grouped(name_for_error = "smooth_data", subset_by = subset_by) :
smooth_data called outside of dplyr::mutate and subset_by = NULL
(this is my first time asking questions in stack overflow, so if there are details I need to include that I did not, kindly fill me in)