################################################################################
#
#' Lot Quality Assurance Sampling (LQAS) algorithm using a two standard, three
#' class classification scheme.
#'
#' @param x A numeric vector
#' @param upper A numeric value between 0 to 1 specifying the upper standard to
#' use for classifying. Default is 0.8
#' @param lower A numeric value between 0 to 1 specifying the lower standard to
#' use for classifying. Default is 0.5
#' @return A character vector providing corresponding classes. Can be either
#' "High", "Moderate", "Low".
#' @examples
#' #
#'
#' @export
#'
#
################################################################################
applyLQAS <- function(x,
upper = 0.8,
lower = 0.5) {
cases <- sum(x, na.rm = TRUE)
total <- length(x)
d1 <- floor(total * lower)
d2 <- floor(total * upper)
class <- ifelse(cases <= d1, "Low",
ifelse(cases > d2, "High", "Moderate"))
return(class)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.