Examples for 'base::encodeString'


Encode Character Vector as for Printing

Aliases: encodeString

Keywords: utilities

### ** Examples

x <- "ab\bc\ndef"
print(x)
[1] "ab\bc\ndef"
cat(x) # interprets escapes
abc
def
cat(encodeString(x), "\n", sep = "") # similar to print()
ab\bc\ndef
factor(x) # makes use of this to print the levels
[1] ab\bc\ndef
Levels: ab\bc\ndef
x <- c("a", "ab", "abcde")
encodeString(x) # width = 0: use as little as possible
[1] "a"     "ab"    "abcde"
encodeString(x, 2) # use two or more (left justified)
[1] "a "    "ab"    "abcde"
encodeString(x, width = NA) # left justification
[1] "a    " "ab   " "abcde"
encodeString(x, width = NA, justify = "c")
[1] "  a  " " ab  " "abcde"
encodeString(x, width = NA, justify = "r")
[1] "    a" "   ab" "abcde"
encodeString(x, width = NA, quote = "'", justify = "r")
[1] "    'a'" "   'ab'" "'abcde'"

[Package base version 4.2.3 Index]