EVOLUTION-MANAGER
Edit File: f_eval.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: Evaluate a formula</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 f_eval_rhs {lazyeval}"><tr><td>f_eval_rhs {lazyeval}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Evaluate a formula</h2> <h3>Description</h3> <p><code>f_eval_rhs</code> evaluates the RHS of a formula and <code>f_eval_lhs</code> evaluates the LHS. <code>f_eval</code> is a shortcut for <code>f_eval_rhs</code> since that is what you most commonly need. </p> <h3>Usage</h3> <pre> f_eval_rhs(f, data = NULL) f_eval_lhs(f, data = NULL) f_eval(f, data = NULL) find_data(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>f</code></td> <td> <p>A formula. Any expressions wrapped in <code> uq() </code> will will be "unquoted", i.e. they will be evaluated, and the results inserted back into the formula. See <code><a href="f_interp.html">f_interp</a></code> for more details.</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>A list (or data frame). <code>find_data</code> is a generic used to find the data associated with a given object. If you want to make <code>f_eval</code> work for your own objects, you can define a method for this generic.</p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>An object for which you want to find associated data.</p> </td></tr> </table> <h3>Details</h3> <p>If <code>data</code> is specified, variables will be looked for first in this object, and if not found in the environment of the formula. </p> <h3>Pronouns</h3> <p>When used with <code>data</code>, <code>f_eval</code> provides two pronouns to make it possible to be explicit about where you want values to come from: <code>.env</code> and <code>.data</code>. These are thin wrappers around <code>.data</code> and <code>.env</code> that throw errors if you try to access non-existent values. </p> <h3>Examples</h3> <pre> f_eval(~ 1 + 2 + 3) # formulas automatically capture their enclosing environment foo <- function(x) { y <- 10 ~ x + y } f <- foo(1) f f_eval(f) # If you supply data, f_eval will look their first: f_eval(~ cyl, mtcars) # To avoid ambiguity, you can use .env and .data pronouns to be # explicit: cyl <- 10 f_eval(~ .data$cyl, mtcars) f_eval(~ .env$cyl, mtcars) # Imagine you are computing the mean of a variable: f_eval(~ mean(cyl), mtcars) # How can you change the variable that's being computed? # The easiest way is "unquote" with uq() # See ?f_interp for more details var <- ~ cyl f_eval(~ mean( uq(var) ), mtcars) </pre> <hr /><div style="text-align: center;">[Package <em>lazyeval</em> version 0.2.2 <a href="00Index.html">Index</a>]</div> </body></html>