magpply: magpply

View source: R/magpply.R

magpplyR Documentation

magpply

Description

apply command for magpieobjects. Very efficient for replacing loops.

Usage

magpply(X, FUN, MARGIN = NULL, DIM = NULL, ..., INTEGRATE = FALSE)

Arguments

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).

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

Value

magpie object

Author(s)

Jan Philipp Dietrich, Benjamin Leon Bodirsky

Examples


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))

magclass documentation built on May 29, 2024, 6:20 a.m.