R/nanmean4.R

Defines functions nanmean4

Documented in nanmean4

#' Mean of the n highest values of a vector.
#'
#' @description Estimates the mean of the n% highest values in vector x.
#'
#' @param x a vector with the values to average
#' @param n an integer corresponding to the percentage of values to use
#'
#' @return mean of the n% highest values in vector x

nanmean4<-function(x,n){
  p<-length(x)

  p1<-ceiling((n*p[1])/100)

  ind<-sort(x,decreasing = TRUE)
  y<-mean(ind[1:p1],na.rm = TRUE)
}

Try the specieschrom package in your browser

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

specieschrom documentation built on Oct. 17, 2022, 5:11 p.m.