mov_avg {hydrotoolbox} | R Documentation |
Moving average windows
Description
Smooth numeric series with a moving average windows.
Usage
mov_avg(
x,
col_name = "last",
k,
pos = "c",
out_name = NULL,
from = NULL,
to = NULL
)
Arguments
x |
data frame (or tibble) with class |
col_name |
string vector with the column(s) name(s) of the series to smooth. The default value
uses the |
k |
numeric vector with the windows size. E.g.: |
pos |
string vector with the position of the windows:
|
out_name |
optional. String vector with new column names. If you set it as |
from |
optional. String value for |
to |
optional. String value for |
Value
The same data frame but with the smooth series.
Examples
# read guido daily streamflow records
path <- system.file('extdata', 'snih_qd_guido.xlsx',
package = 'hydrotoolbox')
# read and apply the function
qd_guido <-
read_snih(path = path, by = 'day', out_name = 'q(m3/s)') %>%
mov_avg(k = 5, out_name = 'q_smooth')