magclass (version 4.107.0)

magpply: magpply

Description

apply command for magpieobjects. Very efficient for replacing loops.

Usage

magpply(X, FUN, MARGIN, ..., 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

...

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

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
data("population_magpie")
magpply(population_magpie,FUN=sum,MARGIN=2)
fourdim<-population_magpie*setNames(population_magpie,c("jkk","lk"))
magpply(fourdim,FUN=sum,MARGIN=c(1,3.1))
magpply(fourdim,FUN=function(x){return(x+1)},MARGIN=c(1,3.1),integrate=TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab