EVOLUTION-MANAGER
Edit File: delete.response.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: Modify Terms Objects</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 delete.response {stats}"><tr><td>delete.response {stats}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Modify Terms Objects</h2> <h3>Description</h3> <p><code>delete.response</code> returns a <code>terms</code> object for the same model but with no response variable. </p> <p><code>drop.terms</code> removes variables from the right-hand side of the model. There is also a <code>"[.terms"</code> method to perform the same function (with <code>keep.response = TRUE</code>). </p> <p><code>reformulate</code> creates a formula from a character vector. If <code>length(termlabels) > 1</code>, its elements are concatenated with <code>+</code>. Non-syntactic names (e.g. containing spaces or special characters; see <code><a href="../../base/html/make.names.html">make.names</a></code>) must be protected with backticks (see examples). A non-<code><a href="../../base/html/parse.html">parse</a></code>able <code>response</code> still works for now, back compatibly, with a deprecation warning. </p> <h3>Usage</h3> <pre> delete.response(termobj) reformulate(termlabels, response = NULL, intercept = TRUE, env = parent.frame()) drop.terms(termobj, dropx = NULL, keep.response = FALSE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>termobj</code></td> <td> <p>A <code>terms</code> object</p> </td></tr> <tr valign="top"><td><code>termlabels</code></td> <td> <p>character vector giving the right-hand side of a model formula. Cannot be zero-length.</p> </td></tr> <tr valign="top"><td><code>response</code></td> <td> <p>character string, symbol or call giving the left-hand side of a model formula, or <code>NULL</code>.</p> </td></tr> <tr valign="top"><td><code>intercept</code></td> <td> <p>logical: should the formula have an intercept?</p> </td></tr> <tr valign="top"><td><code>env</code></td> <td> <p>the <code><a href="../../base/html/environment.html">environment</a></code> of the <code><a href="formula.html">formula</a></code> returned.</p> </td></tr> <tr valign="top"><td><code>dropx</code></td> <td> <p>vector of positions of variables to drop from the right-hand side of the model.</p> </td></tr> <tr valign="top"><td><code>keep.response</code></td> <td> <p>Keep the response in the resulting object?</p> </td></tr> </table> <h3>Value</h3> <p><code>delete.response</code> and <code>drop.terms</code> return a <code>terms</code> object. </p> <p><code>reformulate</code> returns a <code>formula</code>. </p> <h3>See Also</h3> <p><code><a href="terms.html">terms</a></code></p> <h3>Examples</h3> <pre> ff <- y ~ z + x + w tt <- terms(ff) tt delete.response(tt) drop.terms(tt, 2:3, keep.response = TRUE) tt[-1] tt[2:3] reformulate(attr(tt, "term.labels")) ## keep LHS : reformulate("x*w", ff[[2]]) fS <- surv(ft, case) ~ a + b reformulate(c("a", "b*f"), fS[[2]]) ## using non-syntactic names: reformulate(c("`P/E`", "`% Growth`"), response = as.name("+-")) x <- c("a name", "another name") try( reformulate(x) ) # -> Error ..... unexpected symbol ## rather backquote the strings in x : reformulate(sprintf("`%s`", x)) stopifnot(identical( ~ var, reformulate("var")), identical(~ a + b + c, reformulate(letters[1:3])), identical( y ~ a + b, reformulate(letters[1:2], "y")) ) </pre> <hr /><div style="text-align: center;">[Package <em>stats</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>