R/meanUnique.R

Defines functions meanUnique

Documented in meanUnique

#' Calulate mean or take unique elements of a vector
#'
#' A function that calulate mean or take unique elements of a vector.
#'
#' @param x a vector
#' @return If x is numeric, returns the mean. Otherwise, returns the unique elements of x.
#' @examples
#' x <- 1:5
#' meanUnique(x)
#' x=c("a","a","b")
#' meanUnique(x)
#' @export

meanUnique <- function(x){
  if(is.numeric(x)){
    return(mean(x,na.rm = TRUE))
  }else(return(unique(x)))
}

Try the CytoDx package in your browser

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

CytoDx documentation built on Nov. 8, 2020, 11 p.m.