movAvg {hydroToolkit}R Documentation

Moving average windows

Description

Smooth a numeric serie with a moving average windows

Usage

movAvg(df, k, pos)

Arguments

df

data frame with the serie that you want to smooth. By default, t he function uses column 2.

k

numeric value with windows size., e.g.: 5

pos

string with the position of the window:

  • 'izq': left aligned. The output value is on the left, so the function weights the (k - 1) values at the right side.

  • 'der': right aligned. The output value is on the right, so the function weights the (k - 1) values at the left side.

  • 'cen': center. The output value is in the middle of the window.

Value

data frame with the smooth serie.

Examples

# Relative path to raw data
full_path <- system.file('extdata', package = "hydroToolkit")

# Apply function
cuevas <- read_IANIGLA(file = 'Cuevas.csv', path = full_path)   
               
# Get air temperature
cuevas_tair <- cuevas[ , 1:2]

# Create a moving average serie of Tair
Tair_mov <- movAvg(df = cuevas_tair, k = 10, pos = 'izq')


[Package hydroToolkit version 0.1.0 Index]