Evaluates new variables as if they had been part of the formula of the
specified model. This ensures that the same
subset arguments are applied and allows, for example,
to be recovered for a model using
sin(x) as a predictor.
expand.model.frame(model, extras, envir = environment(formula(model)), na.expand = FALSE)
a fitted model
one-sided formula or vector of character strings describing new variables to be added
an environment to evaluate things in
logical; see below
na.expand = FALSE then
NA values in the extra variables
will be passed to the
na.action function used in
model. This may result in a shorter data frame (with
na.omit) or an error (with
na.expand = TRUE the returned data frame will have precisely the
same rows as
model.frame(model), but the columns corresponding to
the extra variables may contain
A data frame.
model <- lm(log(Volume) ~ log(Girth) + log(Height), data = trees) expand.model.frame(model, ~ Girth) # prints data.frame like dd <- data.frame(x = 1:5, y = rnorm(5), z = c(1,2,NA,4,5)) model <- glm(y ~ x, data = dd, subset = 1:4, na.action = na.omit) expand.model.frame(model, "z", na.expand = FALSE) # = default expand.model.frame(model, "z", na.expand = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.