set_threshold: Set a threshold

View source: R/ff_set_threshold.R

set_thresholdR Documentation

Set a threshold

Description

Set tolerable extreme values (maximum or minimum). Records greater or equal than ('>=') or lesser or equal than ('<=') 'threshold' argument are set to NA_real_.

Usage

set_threshold(x, col_name, out_name = NULL, threshold, case = ">=")

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.

threshold

numeric vector with the threshold value(s). If you provide a single value it will be recycled among col_name strings.

case

string with either ">=" (greater or equal than) or "<=" (lesser or equal than) symbol. Default string is ">=".

Value

The same data frame but with the threshold set.

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 values higher than 1.50 meters
cuevas %>%
  set_threshold(col_name = 'hsnow(cm)',
                out_name = 'hsnow_thres',
                threshold = 150 )



hydrotoolbox documentation built on April 14, 2023, 12:34 a.m.