R/weighted.cov2.R

Defines functions weighted.cov2

Documented in weighted.cov2

weighted.cov2 <- function(x, y = NULL, weights = NULL, na.rm = FALSE) {
  if (is.null(weights)) weights <- rep(1, nrow(x))
  if (any(is.na(weights))) stop("There are empty values in weights.")
  if(is.null(y)) {
    sapply(x, function(z) sapply(x, weighted.cov, y = z, weights = weights, na.rm = na.rm))
  } else {
    sapply(y, function(z) sapply(x, weighted.cov, y = z, weights = weights, na.rm = na.rm))
  }}

Try the descriptio package in your browser

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

descriptio documentation built on May 29, 2024, 9:40 a.m.