EVOLUTION-MANAGER
Edit File: as_labeller.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: Coerce to labeller function</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 as_labeller {ggplot2}"><tr><td>as_labeller {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Coerce to labeller function</h2> <h3>Description</h3> <p>This transforms objects to labeller functions. Used internally by <code><a href="labeller.html">labeller()</a></code>. </p> <h3>Usage</h3> <pre> as_labeller(x, default = label_value, multi_line = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>Object to coerce to a labeller function. If a named character vector, it is used as a lookup table before being passed on to <code>default</code>. If a non-labeller function, it is assumed it takes and returns character vectors and is applied to the labels. If a labeller, it is simply applied to the labels.</p> </td></tr> <tr valign="top"><td><code>default</code></td> <td> <p>Default labeller to process the labels produced by lookup tables or modified by non-labeller functions.</p> </td></tr> <tr valign="top"><td><code>multi_line</code></td> <td> <p>Whether to display the labels of multiple factors on separate lines. This is passed to the labeller function.</p> </td></tr> </table> <h3>See Also</h3> <p><code><a href="labeller.html">labeller()</a></code>, <a href="labellers.html">labellers</a> </p> <h3>Examples</h3> <pre> p <- ggplot(mtcars, aes(disp, drat)) + geom_point() p + facet_wrap(~am) # Rename labels on the fly with a lookup character vector to_string <- as_labeller(c(`0` = "Zero", `1` = "One")) p + facet_wrap(~am, labeller = to_string) # Quickly transform a function operating on character vectors to a # labeller function: appender <- function(string, suffix = "-foo") paste0(string, suffix) p + facet_wrap(~am, labeller = as_labeller(appender)) # If you have more than one faceting variable, be sure to dispatch # your labeller to the right variable with labeller() p + facet_grid(cyl ~ am, labeller = labeller(am = to_string)) </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>