encodeString(base)
encodeString()所属R语言包:base
Encode Character Vector as for Printing
打印编码为特征向量
译者:生物统计家园网 机器人LoveR
描述----------Description----------
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.
encodeString逃脱在以同样的方式的特征向量的字符串print.default,可以选择适合内场宽度编码的字符串。
用法----------Usage----------
encodeString(x, width = 0, quote = "", na.encode = TRUE,
justify = c("left", "right", "centre", "none"))
参数----------Arguments----------
参数:x
A character vector, or an object that can be coerced to one by as.character.
一个特征向量,或一个可以强制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.
整数:最小字段宽度。如果NULL或NA,这是最大的领域任何x元素所需的宽度。
参数:quote
character: quoting character, if any.
性格:引用字符,如果有的话。
参数:na.encode
logical: should NA strings be encoded?
逻辑:应NA字符串进行编码?
参数: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.
特点:允许部分匹配。如果需要填充到最小字段宽度的空间,应该如何插入? justify == "none"是width = 0,format.default的一致性。
Details
详情----------Details----------
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).
这反斜杠转义和控制字符\a(钟),\b(退格),\f(换页),\n(换行),\r(回车),\t(标签)和\v(垂直制表符)以及单字节语言环境中的任何非打印字符,这是印在八进制符号(\xyz前导零)。
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 print.default for how non-printable characters are handled in multi-byte locales.
这是不可打印的字符依赖于当前语言环境。 Windows的可打印字符的报告是不可靠的,因此所有其他的控制字符视为非打印,所有字符打印在单字节语言环境与代码32-255。看到print.default非打印字符如何处理多字节语言环境中。
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.
如果quote是一个单或双引号的任何同类型的嵌入引号进行转义。请注意,理由是带引号的字符串,因此空间加引号外。
值----------Value----------
A character vector of the same length as x, with the same attributes (including names and dimensions) but with no class set.
x,具有相同的属性(包括名称和尺寸),但无类集的长度相同的特征向量。
注意----------Note----------
The default for width is different from format.default, which does similar things for character vectors but without encoding using escapes.
width默认format.default类似的事情,这确实为特征向量,但没有编码使用逃逸是不同的。
参见----------See Also----------
print.default
print.default
举例----------Examples----------
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")
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|