mcapply function

Apply Functions Over mc or mcnode Objects

Apply Functions Over mc or mcnode Objects

Apply a function on all values or over a given dimension of an mcnode object. May be used for all mcnode of an mc object.

mcapply(x, margin=c("all", "var", "unc", "variates"), fun, ...)

Examples

data(total) xVUM mcapply(xVUM, "unc", sum) mcapply(xVUM, "var", sum) mcapply(xVUM, "all", sum) mcapply(xVUM, "variates", sum) mcapply(total, "all", exp)

Arguments

  • x: A mc or a mcnode object.

  • margin: The dimension on which applying the function. Maybe "all" (default) to apply the function on all values, "var" to apply the function on the variability dimension, "unc" to apply the function on the uncertainty dimension, or "variates" to apply the function on the variates. Watch out: do not use 'var' for 'variates'

  • fun: The function to be applied. When applied to a vector of length n , fun should return a vector of length n

    or 1 .

  • ...: Optional arguments to fun .

Returns

If fun returns a function of length n or if margin="all" , the returned mcnode s are of type and dimension of x . In other cases, the type of mcnode is changed.

See Also

apply, mc, mcnode.

  • Maintainer: Regis Pouillot
  • License: GPL (>= 2)
  • Last published: 2024-06-05

Useful links