preprocess_validation <- function(x, validation_col = VALIDATION_LEVEL, verbose = TRUE) {
val_col <- rlang::enquo(validation_col)
if (!is.character(dplyr::pull(x, !! val_col))) stop("validation_col must be a character string.")
val.vec <- x %>%
dplyr::select(!! val_col) %>%
dplyr::distinct() %>%
dplyr::pull()
expected_val.vec <- c("Detected Not Quantified",
"Not Detected",
"Not Reported")
unexpected_val.vec <- val.vec[!val.vec %in% expected_val.vec]
if (length(unexpected_val.vec) > 0) stop(paste("preprocess_validation() does not know how to handle the following string(s):",
paste(unexpected_val.vec, collapse = ", ")))
final.df <- x %>%
dplyr::filter(!! val_col %in% c("Detected Not Quantified",
"Not Detected"))
n_dropped_rows.scalar <- nrow(x) - nrow(final.df)
if (verbose == TRUE) print(paste("Dropping",
n_dropped_rows.scalar,
"values from the data frame representing 'Not Reported'."))
return(final.df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.