encodeString package:base R Documentation _E_n_c_o_d_e _C_h_a_r_a_c_t_e_r _V_e_c_t_o_r _a_s _f_o_r _P_r_i_n_t_i_n_g _D_e_s_c_r_i_p_t_i_o_n: 'encodeString' escapes the strings in a character vector in the same way 'print.default' does, and optionally fits the encoded strings within a field width. _U_s_a_g_e: encodeString(x, width = 0, quote = "", na.encode = TRUE, justify = c("left", "right", "centre", "none")) _A_r_g_u_m_e_n_t_s: 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'. _D_e_t_a_i_l_s: 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.) See 'print.default' for how non-printable characters are handled in multi-byte locales. If '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. _V_a_l_u_e: A character vector of the same length as 'x', with the same attributes (including names and dimensions) but with no class set. _N_o_t_e: The default for 'width' is different from 'format.default', which does similar things for character vectors but without encoding using escapes. _S_e_e _A_l_s_o: 'print.default' _E_x_a_m_p_l_e_s: 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 = NA) # left justification encodeString(x, width = NA, justify = "c") encodeString(x, width = NA, justify = "r") encodeString(x, width = NA, quote = "'", justify = "r")