EVOLUTION-MANAGER
Edit File: deparseOpts.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: Options for 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 deparseOpts {base}"><tr><td>deparseOpts {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Options for Expression Deparsing</h2> <h3>Description</h3> <p>Process the deparsing options for <code>deparse</code>, <code>dput</code> and <code>dump</code>. </p> <h3>Usage</h3> <pre> .deparseOpts(control) ..deparseOpts </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>control</code></td> <td> <p>character vector of deparsing options.</p> </td></tr> </table> <h3>Details</h3> <p><code>..deparseOpts</code> is the <code><a href="character.html">character</a></code> vector of possible deparsing options used by <code>.deparseOpts()</code>. </p> <p><code>.deparseOpts()</code> is called by <code><a href="deparse.html">deparse</a></code>, <code><a href="dput.html">dput</a></code> and <code><a href="dump.html">dump</a></code> to process their <code>control</code> argument. </p> <p>The <code>control</code> argument is a vector containing zero or more of the following strings (exactly those in <code>..deparseOpts</code>). Partial string matching is used. </p> <dl> <dt><code>"keepInteger"</code>:</dt><dd> <p>Either surround integer vectors by <code>as.integer()</code> or use suffix <code>L</code>, so they are not converted to type double when parsed. This includes making sure that integer <code>NA</code>s are preserved (via <code>NA_integer_</code> if there are no non-<code>NA</code> values in the vector, unless <code>"S_compatible"</code> is set). </p> </dd> <dt><code>"quoteExpressions"</code>:</dt><dd> <p>Surround unevaluated expressions, but not <code><a href="../../stats/html/formula.html">formula</a></code>s, with <code>quote()</code>, so they are not evaluated when re-parsed. </p> </dd> <dt><code>"showAttributes"</code>:</dt><dd> <p>If the object has <code><a href="attributes.html">attributes</a></code> (other than a <code>source</code> attribute, see <code><a href="srcfile.html">srcref</a></code>), use <code><a href="structure.html">structure</a>()</code> to display them as well as the object value unless the only such attribute is <code>names</code> and the <code>"niceNames"</code> option is set. This (<code>"showAttributes"</code>) is the default for <code><a href="deparse.html">deparse</a></code> and <code><a href="dput.html">dput</a></code>. </p> </dd> <dt><code>"useSource"</code>:</dt><dd> <p>If the object has a <code>source</code> attribute (<code><a href="srcfile.html">srcref</a></code>), display that instead of deparsing the object. Currently only applies to function definitions. </p> </dd> <dt><code>"warnIncomplete"</code>:</dt><dd> <p>Some exotic objects such as <a href="environment.html">environment</a>s, external pointers, etc. can not be deparsed properly. This option causes a warning to be issued if the deparser recognizes one of these situations. </p> <p>Also, the parser in <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> < 2.7.0 would only accept strings of up to 8192 bytes, and this option gives a warning for longer strings. </p> </dd> <dt><code>"keepNA"</code>:</dt><dd> <p>Integer, real and character <code>NA</code>s are surrounded by coercion functions where necessary to ensure that they are parsed to the same type. Since e.g. <code>NA_real_</code> can be output in <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span>, this is mainly used in connection with <code>S_compatible</code>. </p> </dd> <dt><code>"niceNames"</code>:</dt><dd> <p>If true, <code><a href="list.html">list</a></code>s and atomic vectors with non-<code><a href="NA.html">NA</a></code> names (see <code><a href="names.html">names</a></code>) are deparsed as e.g., <code>c(A = 1)</code> instead of <code>structure(1, .Names = "A")</code>, independently of the <code>"showAttributes"</code> setting. </p> </dd> <dt><code>"all"</code>:</dt><dd> <p>An abbreviated way to specify all of the options listed above. This is the default for <code>dump</code>, and the options used by <code><a href="../../utils/html/edit.html">edit</a></code> (which are fixed). </p> </dd> <dt><code>"delayPromises"</code>:</dt><dd> <p>Deparse promises in the form <promise: expression> rather than evaluating them. The value and the environment of the promise will not be shown and the deparsed code cannot be sourced. </p> </dd> <dt><code>"S_compatible"</code>:</dt><dd> <p>Make deparsing as far as possible compatible with S and <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> < 2.5.0. For compatibility with S, integer values of double vectors are deparsed with a trailing decimal point. Backticks are not used. </p> </dd> <dt><code>"hexNumeric"</code>:</dt><dd> <p>Real and finite complex numbers are output in <span class="samp">"%a"</span> format as binary fractions (coded as hexadecimal: see <code><a href="sprintf.html">sprintf</a></code>) with maximal opportunity to be recorded exactly to full precision. Complex numbers with one or both non-finite components are output as if this option were not set. </p> <p>(This relies on that format being correctly supported: known problems on Windows are worked around as from <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> 3.1.2.) </p> </dd> <dt><code>"digits17"</code>:</dt><dd> <p>Real and finite complex numbers are output using format <span class="samp">"%.17g"</span> which may give more precision than the default (but the output will depend on the platform and there may be loss of precision when read back). Complex numbers with one or both non-finite components are output as if this option were not set. </p> </dd> </dl> <p>For the most readable (but perhaps incomplete) display, use <code>control = NULL</code>. This displays the object's value, but not its attributes. The default in <code><a href="deparse.html">deparse</a></code> is to display the attributes as well, but not to use any of the other options to make the result parseable. (<code><a href="dput.html">dput</a></code> and <code><a href="dump.html">dump</a></code> do use more default options, and printing of functions without sources uses <code>c("keepInteger", "keepNA")</code>.) </p> <p>Using <code>control = c("all", "hexNumeric")</code> comes closest to making <code>deparse()</code> an inverse of <code>parse()</code>, as representing double and complex numbers as decimals may well not be exact. However, not all objects are deparse-able even with this option. A warning will be issued if the function recognizes that it is being asked to do the impossible. </p> <p>Only one of <code>"hexNumeric"</code> and <code>"digits17"</code> can be specified. </p> <h3>Value</h3> <p>An integer value corresponding to the <code>control</code> options selected. </p> <h3>Examples</h3> <pre> (iOpt.all <- .deparseOpts("all")) # a four digit integer ## one integer --> vector binary bits int2bits <- function(x, base = 2L, ndigits = 1 + floor(1e-9 + log(max(x,1), base))) { r <- numeric(ndigits) for (i in ndigits:1) { r[i] <- x%%base if (i > 1L) x <- x%/%base } rev(r) # smallest bit at left } int2bits(iOpt.all) ## what options does "all" contain ? (oa <- ..deparseOpts[-1][int2bits(iOpt.all) == 1]) stopifnot(identical(iOpt.all, .deparseOpts(oa))) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>