R/index.prcXXth.R

Defines functions index.prcXXth

Documented in index.prcXXth

#' @title Sample quantiles
#' @description Function to compute the sample quantiles for the given probabilities. 
#' @author Neyko Neykov \email{neyko.neykov@@meteo.bg}, J. Bedia, D. San-Mart\'in, S. Herrera
#' 
#' @param ts A vector containing the data
#' @param prob A float number in the range [0,1] defining the probability of the quantile to be calculated.
#' @param threshold Optional parameter. Remove data below the threshold value.
#'                  Included to consider the case of precipitation. NULL by default.
#' @return A float number corresponding to the quantile.
#' @export


index.prcXXth <- function(ts, prob = .25, threshold = NULL) {
      if (!is.null(threshold)) ts[ts < threshold] <- NA
      quantile(ts, probs = prob, type = 7, na.rm = TRUE)
}
SantanderMetGroup/R_VALUE documentation built on July 4, 2023, 4:27 a.m.