rm_spike: Remove spikes

View source: R/ff_rm_spike.R

rm_spikeR Documentation

Remove spikes

Description

Remove spikes and set their value as NA_real_.

Usage

rm_spike(x, col_name, out_name = NULL, tolerance)

Arguments

x

data frame or tibble with class Date or POSIX* in the first column.

col_name

string with column(s) name(s) where to apply the function.

out_name

optional. String with new column(s) name(s). If you set it as NULL, the function will overwrite the original table.

tolerance

numeric vector with the maximum tolerance between a number and its successor. If you provide a single value it will be recycled.

Value

The same table but with the peaks removed.

Examples


# set path to file
path_file <- system.file('extdata', 'ianigla_cuevas.csv',
             package = 'hydrotoolbox')

# read with default names
cuevas <- read_ianigla(path = path_file,
                       out_name = c('tair(°C)', 'rh(%)', 'patm(mbar)',
                                    'p(mm)', 'wspd(km/hr)', 'wdir(°)',
                                    'kin(kW/m2)', 'hsnow(cm)', 'tsoil(°C)') )

# remove spikes in snow heigh series
cuevas %>%
  rm_spike(col_name = 'hsnow(cm)',
           out_name = 'hsnow',
           tolerance = 50) # 50 cm of snow its OK for this zone



hydrotoolbox documentation built on Oct. 25, 2022, 1:05 a.m.