encodeString escapes the strings in a character vector in the
print.default does, and optionally fits the encoded
strings within a field width.
encodeString(x, width = 0, quote = "", na.encode = TRUE, justify = c("left", "right", "centre", "none"))
A character vector, or an object that can be coerced to one
integer: the minimum field width. If
character: quoting character, if any.
character: partial matches are allowed. If padding to
the minimum field width is needed, how should spaces be inserted?
This escapes backslash and the control characters \a (bell), \b (backspace), \f (formfeed), \n (line feed), \r (carriage return), \t (tab) and \v (vertical tab) as well as any non-printable characters in a single-byte locale, which are printed in octal notation (\xyz with leading zeroes).
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.
print.default for how non-printable characters are
handled in multi-byte locales.
quote 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.
A character vector of the same length as
x, with the same
attributes (including names and dimensions) but with no class set.
Marked UTF-8 encodings are preserved.
The default for
width is different from
which does similar things for character vectors but without encoding
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.