| ModelEnv-class {modeltools} | R Documentation |
A class for model environments.
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 can be created by calls of the form new("ModelEnv", ...).
env:"environment".get:"function" for extracting
objects from environment env.set:"function" for setting
object in environment env.hooks:signature(object = "ModelEnv"): copy an object. signature(object = "ModelEnv", which = "character"):
get the dimension of an object. signature(object = "ModelEnv", which = "character"):
check if an object which is available in env. signature(.Object = "ModelEnv"): setup new
objects.signature(object = "ModelEnv"): show object. signature(x = "ModelEnv"): extract subsets from an
object. na.action method for ModelEnv objects.na.action method for ModelEnv objects.na.action method for ModelEnv objects.
### a new object
me <- new("ModelEnv")
### define a bivariate response variable
me@set("response", data.frame(y = rnorm(10), x = runif(10)))
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)