R/mean2.R

Defines functions mean2

Documented in mean2

#' trancate data and take mean
#' @keywords internal
#' @export
mean2 = function(x){
  x = x[!is.na(x)]
  x_new = sort(x)
  l = length(x)
  if(l<5) warning("The vector has less than 5 non-na values!")
  low = ceiling(l*.05)
  high = l-low
  x[1:low] = x[low+1]
  x[high:l] = x[high-1]
  return(mean(x))
}

Try the EstMix package in your browser

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

EstMix documentation built on May 2, 2019, 7:25 a.m.