Learn R Programming

smint (version 0.4.2)

apply_Grid: 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.

Value

A vector of values.

Details

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

See Also

array_Grid to reshape the result as an array.

Examples

Run this code
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))

Run the code above in your browser using DataLab