Apply a single function or a collection of functions to the data objects stored in a model environment.

# S4 method for class 'ModelEnv'
MEapply(object, FUN, clone = TRUE, ...)

Arguments

object

Object of class "ModelEnv".

FUN

Function or list of functions.

clone

If TRUE, return a clone of the original object, if FALSE, modify the object itself.

...

Passed on to FUN.

Examples

data("iris")
me <- ModelEnvFormula(Species+Petal.Width~.-1, data=iris,
                      subset=sample(1:150, 10))

me1 <- MEapply(me, FUN=list(designMatrix=scale,
                            response=function(x) sapply(x, as.numeric)))

me@get("designMatrix")
#>     Sepal.Length Sepal.Width Petal.Length
#> 63           6.0         2.2          4.0
#> 102          5.8         2.7          5.1
#> 111          6.5         3.2          5.1
#> 47           5.1         3.8          1.6
#> 5            5.0         3.6          1.4
#> 24           5.1         3.3          1.7
#> 79           6.0         2.9          4.5
#> 77           6.8         2.8          4.8
#> 130          7.2         3.0          5.8
#> 55           6.5         2.8          4.6
#> attr(,"assign")
#> [1] 1 2 3
me1@get("designMatrix")
#>     Sepal.Length Sepal.Width Petal.Length
#> 63     0.0000000 -1.78725524   0.08481128
#> 102   -0.2621112 -0.71059546   0.75118566
#> 111    0.6552780  0.36606433   0.75118566
#> 47    -1.1795005  1.65805607  -1.36909644
#> 5     -1.3105561  1.22739215  -1.49025541
#> 24    -1.1795005  0.58139628  -1.30851695
#> 79     0.0000000 -0.27993154   0.38770873
#> 77     1.0484449 -0.49526350   0.56944719
#> 130    1.5726673 -0.06459959   1.17524207
#> 55     0.6552780 -0.49526350   0.44828821
#> attr(,"assign")
#> [1] 1 2 3
#> attr(,"scaled:center")
#> Sepal.Length  Sepal.Width Petal.Length 
#>         6.00         3.03         3.86 
#> attr(,"scaled:scale")
#> Sepal.Length  Sepal.Width Petal.Length 
#>    0.7630349    0.4643993    1.6507237