R/expand.weights.r

  expand.weights = function (x, w){
    # expand a list of values and weights to allow brute force
    # calculation of means, frequency distributions, etc.
    weights = sort(unique(w))

    out = NULL
    for (i in weights) {
      a = x[ which(w == i) ]
      b = rep.int(a, i)
      out = c(out, b)
    }
    return(out)
  }

 
jae0/snowcrab documentation built on Feb. 27, 2024, 2:42 p.m.