R/recurrence_interval_prob.R

Defines functions recurrence_interval_prob

Documented in recurrence_interval_prob

#' recurrence_interval_prob
#'
#' This function determines the risk from finding the probability in any given year that a flood of that magnitude will be equaled or exceeded
#' @param Y years in record
#' @param R magnitude ranking
#' @return the risk in in any given year that a flood of that magnitude will be equaled or exceeded
#' @author Claudia Flores

recurrence_interval_prob <- function(Y,R){
  # Body
  T <- Y + 1
  Prob <- (1)/(T/R)
  # Error checking
  R = ifelse((R < 0),
             return("Ranking must be a positive integer"),
             R)
  # Output is the probability
  risk <- case_when( # Print the following "" if certain conditions (e.g. <,>,=...) for Prob results are met
    Prob > 0.5 ~ "High",
    Prob == 0.5 ~ "Medium",
    Prob < 0.5 ~ "Low"
  )
  return(risk)
}
claudiapflores/garage documentation built on March 18, 2021, 2:38 p.m.