R/compute_odds.R

Defines functions get_odds

Documented in get_odds

#' Compute Odds From Probabilities
#' 
#' Compute odds from probabilities. The function is vectorized and can handle a vector of probabilities. 
#' 
#' @param p vector of probabilities. May not be larger than 1 or smaller than zero.
#' @examples
#' get_odds(.8) # 4
#' @export
get_odds <- function(p){
  if(!all(p <= 1 & p >= 0)) stop('Input is not a probability!')
  p / (1-p)
} 

Try the dropR package in your browser

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

dropR documentation built on May 2, 2019, 6:12 a.m.