R/z_outliers.R

#' Detect outliers based on sd
#'
#' This function computes z scores and displays any values 3 sds above or below the mean
#' @keywords outliers
#' @param x a list object
#' @param y a number
#' @export
#' @import dplyr
#' @examples
#' z.outlier()

z.outlier = function(x, y) {
  p = scale(x, center = TRUE)
  
  z.score = p[ p >= y | p <= -y] 
  value = x[ p >=y | p <= -y]
 
  a = data.frame(z.score, value)
  #return(a) #uncomment this to get back to default
  
  if (empty(a) == FALSE){ #
    return(a) } #
    
  if (empty(a) == TRUE) 
    {cat(paste("No Outliers Detected", "\n"))} #
}

#document()
npm27/domo documentation built on July 2, 2019, 11:09 p.m.