R/thresh_determination.R

Defines functions thresh_determination

Documented in thresh_determination

#' Threshold determination for WQS/GV with dynamic thresholds dependent
#'  on one or more independent parmeters
#'
#' @param .data a data frame
#' @return A data frame
#' @export

thresh_determination <- function(.data) {
  split.df <- split(.data, .data$wqs_threshold)

  split.df$thresh_total_ammonia$threshold <- mapply(
    FUN = thresh_total_ammonia,
    .ph = split.df$thresh_total_ammonia$value_ph,
    .temp = split.df$thresh_total_ammonia$value_temperature,
    .trout_water = grepl("(t)|(ts)", split.df$thresh_total_ammonia$class),
    .type = split.df$thresh_total_ammonia$type
    )

  split.df$thresh_hardness_correction$threshold <- mapply(
    FUN = thresh_hardness_correction,
    .param = split.df$thresh_hardness_correction$parameter,
    .hardness = split.df$thresh_hardness_correction$value_hardness,
    .type = split.df$thresh_hardness_correction$type
    )

  final.df <- do.call(rbind, split.df)
  return(final.df)
}
BWAM/stayCALM documentation built on May 21, 2020, 3:24 p.m.