encodeString meloloskan string dalam vektor karakter dengan cara yang sama seperti yang dilakukan print.default, dan secara opsional menyesuaikan string yang dikodekan dalam lebar bidang.
encodeString(x, width = 0, quote = "", na.encode = TRUE,
justify = c("left", "right", "centre", "none"))
| Parameter | Deskripsi |
|---|---|
x |
A character vector, or an object that can be coerced to one by as.character. |
width |
integer: the minimum field width. If NULL or NA, this is taken to be the largest field width needed for any element of x. |
quote |
character: quoting character, if any. |
na.encode |
logical: should NA strings be encoded? |
justify |
character: partial matches are allowed. If padding to the minimum field width is needed, how should spaces be inserted? justify == "none" is equivalent to width = 0, for consistency with format.default. |
# NOT RUN {
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")
# }