EVOLUTION-MANAGER
Edit File: expand.model.frame.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Add new variables to a model frame</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for expand.model.frame {stats}"><tr><td>expand.model.frame {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add new variables to a model frame</h2> <h3>Description</h3> <p>Evaluates new variables as if they had been part of the formula of the specified model. This ensures that the same <code>na.action</code> and <code>subset</code> arguments are applied and allows, for example, <code>x</code> to be recovered for a model using <code>sin(x)</code> as a predictor. </p> <h3>Usage</h3> <pre> expand.model.frame(model, extras, envir = environment(formula(model)), na.expand = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>model</code></td> <td> <p>a fitted model</p> </td></tr> <tr valign="top"><td><code>extras</code></td> <td> <p>one-sided formula or vector of character strings describing new variables to be added</p> </td></tr> <tr valign="top"><td><code>envir</code></td> <td> <p>an environment to evaluate things in</p> </td></tr> <tr valign="top"><td><code>na.expand</code></td> <td> <p>logical; see below</p> </td></tr> </table> <h3>Details</h3> <p>If <code>na.expand = FALSE</code> then <code>NA</code> values in the extra variables will be passed to the <code>na.action</code> function used in <code>model</code>. This may result in a shorter data frame (with <code><a href="na.fail.html">na.omit</a></code>) or an error (with <code><a href="na.fail.html">na.fail</a></code>). If <code>na.expand = TRUE</code> the returned data frame will have precisely the same rows as <code>model.frame(model)</code>, but the columns corresponding to the extra variables may contain <code>NA</code>. </p> <h3>Value</h3> <p>A data frame. </p> <h3>See Also</h3> <p><code><a href="model.frame.html">model.frame</a></code>, <code><a href="predict.html">predict</a></code></p> <h3>Examples</h3> <pre> 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) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>