powered by
apply command for magpieobjects. Very efficient for replacing loops.
magpply(X, FUN, MARGIN, ..., integrate = FALSE)
magpie object
function that shall be applied X
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
if TRUE, the output will be filled into an magpie object of the same dimensionality as X
# NOT RUN { 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)) # }
Run the code above in your browser using DataLab