apply_Grid: Apply a function to a 'Grid' object.

View source: R/GridData.R

apply_GridR Documentation

Apply a function to a Grid object.

Description

Apply a function to a Grid object.

Usage

apply_Grid(object, fun, ...)

Arguments

object

An object with S4 class "Grid"

fun

The function to be applied.

...

Further arguments to be passed to fun.

Details

The function is applied to each vector combination of the levels by first using the as.matrix coercion.

Value

A vector of values.

Note

The result values are given in the order specified by the Grid object.

See Also

array_Grid to reshape the result as an array.

Examples

myGD <- Grid(levels = list("X" = c(0, 1),
                           "Y" = c(0.0, 0.5, 1.0),
                           "Z" = c(0.0, 0.2, 0.4, 1.0)))
## gaussian function
apply_Grid(myGD, fun = function(x) exp(-x[1]^2 - 3 * x[2]^2 - 2 * x[3]^2))



IRSN/smint documentation built on Dec. 9, 2023, 9:53 p.m.