Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

apply-methods

Apply-type iterator for RasterArrays and SpatialArrays


Description

The function implements the apply-type iterators for the RasterArray class. Output values are constrained to RasterArrays, whenever possible. Not yet implemented for multidimensional MARGINs.

Arguments

X

an array, including matrices and RasterArrays.

MARGIN

a vector giving the subscripts which the function will be applied over. E.g., for a matrix 1 indicates rows, 2 indicates columns, c(1, 2) indicates rows and columns. Where X has named dimnames, it can be a character vector selecting dimension names. For RasterArrays only single dimension margins are implemented. If it is NULL then the function is applied to every item.

FUN

the function to be applied: see ‘Details’ of apply.

...

optional arguments passed to FUN.

Format

An object of class standardGeneric of length 1.

Value

Depending on the on the output of FUN, a list, a vector or RasterArray or SpatialArray object.

Examples

# Null dimensional margin
data(coasts)
# apply function to every element manually
# memory taken by every layer
apply(coasts, MARGIN=NULL, object.size)
# double of itself
data(dems)
a<- cbind(dems, dems)
same <- apply(a, 1, sum)

chronosphere

Earth System History Variables

v0.4.1
CC BY 4.0
Authors
Adam T. Kocsis, Nussaibah B. Raja
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.