R/attaining.R

Defines functions attaining

Documented in attaining

#' Old: Is a reported value attaining?
#'
#' @param ... Generally, unquoted column names ordered to form an expression, but can also include
#' explicit expressions and/or operators.
#' @param na.rm a logical value indicating if NA's should be kept (FALSE; default) or removed (TRUE).
#' @return A logical vector.
#' @examples

# wqs_attaining <- function(..., na.rm = FALSE) {
#
#   dots.vec <- paste(...)
#
#   if (na.rm) {
#     dots.vec <- gsub(pattern = "NA",
#                      replacement = "",
#                      x = dots.vec)
#   }
#   if (any(grepl("NA", dots.vec))) stop(paste("To remove NAs set na.rm = TRUE"))
#
#
#   sapply(X = parse(text = dots.vec),
#          FUN = eval)
#
# }

#' Is a reported value attaining?
#'
#' @param .value a numeric vector of observed values.
#' @param .symbol a character vector of symbols, such as "<", "<=", ">", or ">=".
#' @param .threshold a numeric vector of water quality standard or guidance values.
#' @return A logical vector.
#' @examples
#' @export

attaining <- function(.value, .direction, .threshold) {
  mapply(parse_eval,
         paste(.value, .direction, .threshold))

}
BWAM/stayCALM documentation built on May 21, 2020, 3:24 p.m.