Set a value where the actual value of a measurement is less than the method detection limit (MDL)

set_non_detects(
  value,
  mdl_flag = NULL,
  mdl_value = NULL,
  mdl_action = c("zero", "mdl", "half", "na")
)

Arguments

value

a numeric vector of measured values

mdl_flag

a character vector the same length as value that has a "flag" (assumed to be "<") for values that are below the MDL

mdl_value

a numeric vector the same length as value that contains the MDL values.

mdl_action

What to do with values below the detection limit. Options are "zero" (set the value to 0; the default), #' "half" (set the value to half the MDL), "mdl" (set the value to equal to the MDL), or "na" (set the value to NA).

Value

a numeric vector the same length as value with non-detects adjusted accordingly

Details

You must supply either mdl_flag or mdl_value, or both. When only mdl_flag is supplied, it is assumed that the original value has been set to the MDL, and will be adjusted according to the mdl_action. When only mdl_value is supplied then any value less than that will be adjusted appropriately using the corresponding mdl_value. When both mdl_flag and mdl_value are supplied, any value with a corresponding < in the mdl_flag vector will be adjusted appropriately using the corresponding mdl_value.