Sets values outside user-specified physical limits to NA. This is commonly used to remove impossible measurements, such as relative humidity outside 0--100% or negative concentrations. The function supports per-column limits and grouping.
A data frame or vector with out-of-range values set to NA.
Arguments
data
A data frame, matrix, or numeric vector.
cols
Column indices or names of numeric variables to filter. If NULL, all numeric columns are used.
min_val
Lower limit(s). If a single value is given, it is applied to all selected columns. Otherwise, provide a vector with length equal to the number of selected columns.
max_val
Upper limit(s). Same behavior as min_val.
group
Optional grouping column (currently not used but reserved for consistency).
date_col
Optional time column (not used).
verbose
Logical; if TRUE, prints progress message.
Details
Values strictly less than min_val or strictly greater than max_val are set to NA. If min_val or max_val is NULL, that bound is not checked.