applyDistMat3D: Apply function for class DistMat3D

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Apply function to values in a 3-D distance matrix

Usage

1
2
## S4 method for signature 'DistMat3D'
apply(X, MARGIN, FUN, ...)

Arguments

X

Object of class 'DistMat3D'.

MARGIN

A vector giving the subscripts (dimensions) of the DistMat3D-object which the function will be applied over (see details).

FUN

Function to be applied. Matched with match.fun.

...

Further arguments passed to FUN.

Details

The specified function is either applied to the distances of all samples (MARGIN = 1) or to all distances for each sample (MARGIN = 3). In the first case, if X would be replaced by an array of same dimensions the return value would be equal if the following code is applied:

apply(X, MARGIN = c(1,2), FUN),

where X is an array (see examples).

Value

Depending on the length of the return value of the specified function, objects of classes numeric or matrix are returned.

Author(s)

Lukas Lehnert

See Also

apply, match.fun, DistMat3D

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(spectral_data)

## Calculate NDVI
ndvi <- nri(spectral_data, b1=800, b2=680)

## Calculate all possible combinations for WorldView-2-8
spec_WV <- spectralResampling(spectral_data, "WorldView2-8",
                              response_function = FALSE)
nri_WV <- nri(spec_WV, recursive = TRUE)
class(nri_WV@nri)

## Calculate mean value of all samples for all indices 
meanIndexVals <- apply(nri_WV@nri, MARGIN = 1, FUN = mean)
meanIndexVals

## Same but for array
nri_WV_dat <- as.array(nri_WV@nri)
meanIndexVals_arr <- apply(nri_WV_dat, MARGIN = c(1, 2), FUN = mean)

meanSampleVals <- apply(nri_WV@nri, MARGIN = 3, FUN = mean)
meanSampleVals_arr <- apply(nri_WV_dat, MARGIN = 3, FUN = mean)


Search within the hsdar package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.