| ModelEnv-class {modeltools} | R Documentation |
Class "ModelEnv"
Description
A class for model environments.
Details
Objects of class ModelEnv basically consist of an
environment for data storage as well as get and
set methods.
na.fail returns FALSE when at least one missing value occurs
in object@env. na.pass returns object unchanged and
na.omit returns a copy of object with all missing values
removed.
Objects from the Class
Objects can be created by calls of the form new("ModelEnv", ...).
Slots
env:Object of class
"environment".get:Object of class
"function"for extracting objects from environmentenv.set:Object of class
"function"for setting object in environmentenv.hooks:A list of hook collections.
Methods
- clone
signature(object = "ModelEnv"): copy an object.- dimension
signature(object = "ModelEnv", which = "character"): get the dimension of an object.- empty
signature(object = "ModelEnv"): ReturnTRUE, if the model environment contains no data.- has
signature(object = "ModelEnv", which = "character"): check if an objectwhichis available inenv.- initialize
signature(.Object = "ModelEnv"): setup new objects.- show
signature(object = "ModelEnv"): show object.- subset
signature(x = "ModelEnv"): extract subsets from an object.- na.pass
na.actionmethod forModelEnvobjects.- na.fail
na.actionmethod forModelEnvobjects.- na.omit
na.actionmethod forModelEnvobjects.
Examples
### a new object
me <- new("ModelEnv")
## the new model environment is empty
empty(me)
### define a bivariate response variable
me@set("response", data.frame(y = rnorm(10), x = runif(10)))
me
## now it is no longer empty
empty(me)
### check if a response is available
has(me, "response")
### the dimensions
dimension(me, "response")
### extract the data
me@get("response")
df <- data.frame(x = rnorm(10), y = rnorm(10))
## hook for set method:
mf <- ModelEnvFormula(y ~ x-1, data = df, setHook=list(designMatrix=scale))
mf@get("designMatrix")
mf@set(data=df[1:5,])
mf@get("designMatrix")
### NA handling
df$x[1] <- NA
mf <- ModelEnvFormula(y ~ x, data = df, na.action = na.pass)
mf
na.omit(mf)