R/vulnerability.R

Defines functions vulnerability

Documented in vulnerability

vulnerability <- function(data, sp.cols = 1:ncol(data), categories, na.rm = TRUE) {
  
  # version 1.1 (5 Jul 2022)
  
  data <- as.data.frame(data)
  
  if (length(categories) != length(sp.cols)) stop ("'categories' must have the same length as 'sp.cols'")
  
  vuln_total <- 0
  for (i in 1:length(sp.cols)) {
    v <- data[ , sp.cols[i]] * categories[i]
    vuln_total <- vuln_total + v
  }
  vuln_total
}

Try the fuzzySim package in your browser

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

fuzzySim documentation built on Oct. 9, 2023, 5:09 p.m.