magpply | R Documentation |
apply command for magpieobjects. Very efficient for replacing loops.
magpply(X, FUN, MARGIN = NULL, DIM = NULL, ..., INTEGRATE = FALSE)
X |
magpie object |
FUN |
function that shall be applied X |
MARGIN |
dimension over which FUN shall be applied (like a loop over that dimension).
This dimension will be preserved in the output object (see also |
DIM |
dimension in which FUN shall be applied. This dimension will be missing in the output. DIM and MARGIN are opposite ways of expressing the dimensions to be addressed and you must only use one of them with MARGIN excluding dimensions from the calculation and DIM including them. |
... |
further parameters passed on to FUN |
INTEGRATE |
if TRUE, the output will be filled into an magpie object of the same dimensionality as X |
magpie object
Jan Philipp Dietrich, Benjamin Leon Bodirsky
pop <- maxample("pop")
magpply(pop, FUN = sum, MARGIN = 2)
fourdim <- pop * setNames(pop, c("jkk", "lk"))
magpply(fourdim, FUN = sum, MARGIN = c(1, 3.1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.