R/freq.calc.R

Defines functions freq.calc

Documented in freq.calc

freq.calc <-
  function(matr) {
    matr <- as.matrix(matr)
    if (!is.matrix(matr)) {
      stop("The input data must be matrix!\n")
    }
    if (any(is.na(matr))) {
      matr <- na.omit(matr)
      print(paste("NA found in matrix, and have been removed\n"))
    }
    matr[matr > 1] <- 1
    result <- apply(matr, 2, sum) / nrow(matr)
    return(result)
  }

Try the spaa package in your browser

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

spaa documentation built on April 4, 2025, 2:41 a.m.