| phys_filter | R Documentation |
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.
phys_filter(data, cols = NULL, min_val = NULL, max_val = NULL,
group = NULL, date_col = NULL, verbose = FALSE)
data |
A data frame, matrix, or numeric vector. |
cols |
Column indices or names of numeric variables to filter. If |
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 |
group |
Optional grouping column (currently not used but reserved for consistency). |
date_col |
Optional time column (not used). |
verbose |
Logical; if |
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.
A data frame or vector with out-of-range values set to NA.
phys_filter(data[1:100, c(1, 4, 17:19)], cols = 3:5, min_val = 0, max_val = 1000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.