R/calibraR-fitness_aux.R

Defines functions .globalFitness .weighted.sum

.weighted.sum = function(x, w, ..., na.rm=FALSE) {
  if(isTRUE(na.rm)) {
    ind = !is.na(x)
    x = x[ind]
    w = w[ind]
  }
  return(sum(x*w))
}

.globalFitness = function(fitness, opt) {
  # must receive fitness and optionally weight argument
  aggFn = match.fun(opt$aggFn)
  out   = apply(fitness, 1, aggFn, w=opt$weights)
  return(out)

}
roliveros-ramos/calibrar documentation built on March 15, 2024, 12:08 a.m.