EVOLUTION-MANAGER
Edit File: deparse.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: Expression Deparsing</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 deparse {base}"><tr><td>deparse {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Expression Deparsing</h2> <h3>Description</h3> <p>Turn unevaluated expressions into character strings. </p> <h3>Usage</h3> <pre> deparse(expr, width.cutoff = 60L, backtick = mode(expr) %in% c("call", "expression", "(", "function"), control = c("keepNA", "keepInteger", "niceNames", "showAttributes"), nlines = -1L) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>expr</code></td> <td> <p>any <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> expression.</p> </td></tr> <tr valign="top"><td><code>width.cutoff</code></td> <td> <p>integer in <i>[20, 500]</i> determining the cutoff (in bytes) at which line-breaking is tried.</p> </td></tr> <tr valign="top"><td><code>backtick</code></td> <td> <p>logical indicating whether symbolic names should be enclosed in backticks if they do not follow the standard syntax.</p> </td></tr> <tr valign="top"><td><code>control</code></td> <td> <p>character vector (or <code>NULL</code>) of deparsing options. See <code><a href="deparseOpts.html">.deparseOpts</a></code>.</p> </td></tr> <tr valign="top"><td><code>nlines</code></td> <td> <p>integer: the maximum number of lines to produce. Negative values indicate no limit.</p> </td></tr> </table> <h3>Details</h3> <p>This function turns unevaluated expressions (where ‘expression’ is taken in a wider sense than the strict concept of a vector of mode <code>"expression"</code> used in <code><a href="expression.html">expression</a></code>) into character strings (a kind of inverse to <code><a href="parse.html">parse</a></code>). </p> <p>A typical use of this is to create informative labels for data sets and plots. The example shows a simple use of this facility. It uses the functions <code>deparse</code> and <code>substitute</code> to create labels for a plot which are character string versions of the actual arguments to the function <code>myplot</code>. </p> <p>The default for the <code>backtick</code> option is not to quote single symbols but only composite expressions. This is a compromise to avoid breaking existing code. </p> <p>Using <code>control = "all"</code> comes closest to making <code>deparse()</code> an inverse of <code>parse()</code>. However, not all objects are deparse-able even with this option and a warning will be issued if the function recognizes that it is being asked to do the impossible. </p> <p>Numeric and complex vectors are converted using 15 significant digits: see <code><a href="character.html">as.character</a></code> for more details. </p> <p><code>width.cutoff</code> is a lower bound for the line lengths: deparsing a line proceeds until at least <code>width.cutoff</code> <em>bytes</em> have been output and e.g. <code>arg = value</code> expressions will not be split across lines. </p> <h3>Note</h3> <p>To avoid the risk of a source attribute out of sync with the actual function definition, the source attribute of a function will never be deparsed as an attribute. </p> <p>Deparsing internal structures may not be accurate: for example the graphics display list recorded by <code><a href="../../grDevices/html/recordplot.html">recordPlot</a></code> is not intended to be deparsed and <code>.Internal</code> calls will be shown as primitive calls. </p> <h3>References</h3> <p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) <em>The New S Language</em>. Wadsworth & Brooks/Cole. </p> <h3>See Also</h3> <p><code><a href="substitute.html">substitute</a></code>, <code><a href="parse.html">parse</a></code>, <code><a href="expression.html">expression</a></code>. </p> <p><code>Quotes</code> for quoting conventions, including backticks. </p> <h3>Examples</h3> <pre> require(stats); require(graphics) deparse(args(lm)) deparse(args(lm), width = 500) myplot <- function(x, y) { plot(x, y, xlab = deparse(substitute(x)), ylab = deparse(substitute(y))) } e <- quote(`foo bar`) deparse(e) deparse(e, backtick = TRUE) e <- quote(`foo bar`+1) deparse(e) deparse(e, control = "all") # wraps it w/ quote( . ) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>