EVOLUTION-MANAGER
Edit File: encodeString.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: Encode Character Vector as for Printing</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 encodeString {base}"><tr><td>encodeString {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Encode Character Vector as for Printing </h2> <h3>Description</h3> <p><code>encodeString</code> escapes the strings in a character vector in the same way <code>print.default</code> does, and optionally fits the encoded strings within a field width. </p> <h3>Usage</h3> <pre> encodeString(x, width = 0, quote = "", na.encode = TRUE, justify = c("left", "right", "centre", "none")) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A character vector, or an object that can be coerced to one by <code><a href="character.html">as.character</a></code>.</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>integer: the minimum field width. If <code>NULL</code> or <code>NA</code>, this is taken to be the largest field width needed for any element of <code>x</code>.</p> </td></tr> <tr valign="top"><td><code>quote</code></td> <td> <p>character: quoting character, if any.</p> </td></tr> <tr valign="top"><td><code>na.encode</code></td> <td> <p>logical: should <code>NA</code> strings be encoded?</p> </td></tr> <tr valign="top"><td><code>justify</code></td> <td> <p>character: partial matches are allowed. If padding to the minimum field width is needed, how should spaces be inserted? <code>justify == "none"</code> is equivalent to <code>width = 0</code>, for consistency with <code>format.default</code>.</p> </td></tr> </table> <h3>Details</h3> <p>This escapes backslash and the control characters <span class="samp">\a</span> (bell), <span class="samp">\b</span> (backspace), <span class="samp">\f</span> (formfeed), <span class="samp">\n</span> (line feed), <span class="samp">\r</span> (carriage return), <span class="samp">\t</span> (tab) and <span class="samp">\v</span> (vertical tab) as well as any non-printable characters in a single-byte locale, which are printed in octal notation (<span class="samp">\xyz</span> with leading zeroes). </p> <p>Which characters are non-printable depends on the current locale. Windows' reporting of printable characters is unreliable, so there all other control characters are regarded as non-printable, and all characters with codes 32–255 as printable in a single-byte locale. See <code><a href="print.default.html">print.default</a></code> for how non-printable characters are handled in multi-byte locales. </p> <p>If <code>quote</code> is a single or double quote any embedded quote of the same type is escaped. Note that justification is of the quoted string, hence spaces are added outside the quotes. </p> <h3>Value</h3> <p>A character vector of the same length as <code>x</code>, with the same attributes (including names and dimensions) but with no class set. </p> <p>Marked UTF-8 encodings are preserved. </p> <h3>Note</h3> <p>The default for <code>width</code> is different from <code>format.default</code>, which does similar things for character vectors but without encoding using escapes. </p> <h3>See Also</h3> <p><code><a href="print.default.html">print.default</a></code> </p> <h3>Examples</h3> <pre> x <- "ab\bc\ndef" print(x) cat(x) # interprets escapes cat(encodeString(x), "\n", sep = "") # similar to print() factor(x) # makes use of this to print the levels x <- c("a", "ab", "abcde") encodeString(x) # width = 0: use as little as possible encodeString(x, 2) # use two or more (left justified) encodeString(x, width = NA) # left justification encodeString(x, width = NA, justify = "c") encodeString(x, width = NA, justify = "r") encodeString(x, width = NA, quote = "'", justify = "r") </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>