clean_data {topolow} | R Documentation |
Clean Data by Removing MAD-based Outliers
Description
Removes outliers from numeric data using the Median Absolute Deviation method. Outliers are replaced with NA values. This function is particularly useful for cleaning parameter tables where each column may contain outliers.
Usage
clean_data(x, k = 3, take_log = FALSE)
Arguments
x |
Numeric vector to clean |
k |
Numeric threshold for outlier detection (default: 3) |
take_log |
Logical. Whether to log transform data before outlier detection (default: FALSE) |
Value
A numeric vector of the same length as x
, where detected outliers have been replaced with NA
.
See Also
detect_outliers_mad
for the underlying outlier detection
Examples
# Clean parameter values
params <- c(0.01, 0.012, 0.011, 0.1, 0.009, 0.011, 0.15)
clean_params <- clean_data(params)
# Clean multiple parameter columns
param_table <- data.frame(
k0 = runif(100),
cooling_rate = runif(100),
c_repulsion = runif(100)
)
clean_table <- as.data.frame(lapply(param_table, clean_data))
[Package topolow version 1.0.0 Index]