EVOLUTION-MANAGER
Edit File: aes_.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: Define aesthetic mappings programmatically</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 aes_ {ggplot2}"><tr><td>aes_ {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Define aesthetic mappings programmatically</h2> <h3>Description</h3> <p>Aesthetic mappings describe how variables in the data are mapped to visual properties (aesthetics) of geoms. <code><a href="aes.html">aes()</a></code> uses non-standard evaluation to capture the variable names. <code>aes_</code> and <code>aes_string</code> require you to explicitly quote the inputs either with <code>""</code> for <code>aes_string()</code>, or with <code>quote</code> or <code>~</code> for <code>aes_()</code>. (<code>aes_q()</code> is an alias to <code>aes_()</code>). This makes <code>aes_()</code> and <code>aes_string()</code> easy to program with. </p> <h3>Usage</h3> <pre> aes_(x, y, ...) aes_string(x, y, ...) aes_q(x, y, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y, ...</code></td> <td> <p>List of name value pairs. Elements must be either quoted calls, strings, one-sided formulas or constants.</p> </td></tr> </table> <h3>Details</h3> <p><code>aes_string()</code> and <code>aes_()</code> are particularly useful when writing functions that create plots because you can use strings or quoted names/calls to define the aesthetic mappings, rather than having to use <code><a href="../../base/html/substitute.html">substitute()</a></code> to generate a call to <code>aes()</code>. </p> <p>I recommend using <code>aes_()</code>, because creating the equivalents of <code>aes(colour = "my colour")</code> or <code>aes(x = `X$1`)</code> with <code>aes_string()</code> is quite clunky. </p> <h3>Life cycle</h3> <p>All these functions are soft-deprecated. Please use tidy evaluation idioms instead (see the quasiquotation section in <code><a href="aes.html">aes()</a></code> documentation). </p> <h3>See Also</h3> <p><code><a href="aes.html">aes()</a></code> </p> <h3>Examples</h3> <pre> # Three ways of generating the same aesthetics aes(mpg, wt, col = cyl) aes_(quote(mpg), quote(wt), col = quote(cyl)) aes_(~mpg, ~wt, col = ~cyl) aes_string("mpg", "wt", col = "cyl") # You can't easily mimic these calls with aes_string aes(`$100`, colour = "smooth") aes_(~ `$100`, colour = "smooth") # Ok, you can, but it requires a _lot_ of quotes aes_string("`$100`", colour = '"smooth"') # Convert strings to names with as.name var <- "cyl" aes(col = x) aes_(col = as.name(var)) </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>