R/lambda.R

Defines functions fr

Documented in fr

#' Failure Rate (lambda).
#'
#' @param failures Failures. A numeric value representing the number of failures for a given period.
#' @param totalTime Total Time. A numeric value representing the total time for a given period
#' or a numeric vector of time periods
#' @return The function returns a numeric value representing the failure rate (lambda) for a given period.
#' @examples
#' fail <- 75
#' total <- 5000
#' fr(fail, total)
#' @export
fr <- function(failures, totalTime)

{

  # Check for a numeric value of failures
  if(all(!is.null(failures), !is.numeric(failures))) {
    stop("Argument \"failures\" must be a numeric vector")
  }

  # Check for a numeric vector of time periods
  if(all(!is.null(totalTime), !is.numeric(totalTime))) {
    stop("Argument \"totalTime\" must be a numeric vector")
  }

  # Calculate reliability
  fr <-  failures/sum(totalTime)
  print(fr)

}

Try the WeibullR.learnr package in your browser

Any scripts or data that you put into this service are public.

WeibullR.learnr documentation built on Sept. 11, 2024, 9:08 p.m.