R/dist_chopper.R

Defines functions dist_chopper

Documented in dist_chopper

#' A distribution chopper fucntion 
#'
#' This function allows you to chop a distribution into 3 different datasets; left tail, middle body, right tail.
#' @param col The main dataset (distribution)
#' @param tail.prob The probability that defines the tails. A value between 0 to 1. for example for 0.1, lowest 10 percent of data will be concidered as lower tail or left tail.
#' @keywords titanfall 
#' @export
#' @examples
#' dist_chopper(dataset, 0.1)
#' 

dist_chopper <- function(col, tail.prob){
  middle <-  col[(col < quantile(col, probs = (1 - tail.prob)))&(col > quantile(col, probs = tail.prob))]
  left <- col[col < quantile(col, probs = tail.prob)]
  right <- col[col > quantile(col, probs = (1- tail.prob))]
  chopped_col <- list(left = left, middle = middle, right = right)
  return(chopped_col)
}
1mp3rium/titanfall documentation built on Dec. 16, 2017, 2:44 a.m.