ApplyFields: Apply function on two fields

Description Usage Arguments Details Value Author(s) Examples

View source: R/apply-fields.R

Description

Apply a function, which expects two arguments, row-wise, i.e. across space, on two "pField" objects. The result of this gives a "pField" object with only one time step.

Usage

1
ApplyFields(fld1, fld2, FUN, newtime = NULL, ...)

Arguments

fld1

a "pField" object.

fld2

a "pField" object.

FUN

the function to be applied on fld1 and fld2.

newtime

Specify the observation time point corresponding to the resulting "pField" object. For NULL (the default), the average of the time points in fld1 is used.

...

further arguments passed on to FUN.

Details

Note that the currect implementation expects both fields to have the exact same time basis, latitudes and longitudes; any differences will result in an error.

Value

a "pField" object with the results of the function applied.

Author(s)

Thomas Münch

Examples

1
2
3
4
5
x <- pField(data = array(rnorm(10 * 10 * 100), dim = c(10, 10, 100)),
            time = 1 : 100, lat = 1 : 10, lon = 1 : 10)
y <- pField(data = array(rnorm(10 * 10 * 100), dim = c(10, 10, 100)),
            time = 1 : 100, lat = 1 : 10, lon = 1 : 10)
z <- ApplyFields(x, y, cor)

EarthSystemDiagnostics/pfields documentation built on Jan. 10, 2022, 10:37 p.m.