R/wmean.R

Defines functions wmean

Documented in wmean

wmean <- function(x,w=rep(1,length(x)),na.rm=TRUE) {
  if (na.rm) {
    comp <- complete.cases(x,w)
    x <- x[comp]
    w <- w[comp]
  }
  sum(x*w)/sum(w)
}

Try the RVAideMemoire package in your browser

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

RVAideMemoire documentation built on Nov. 6, 2023, 5:07 p.m.