找回密码
 注册
查看: 3330|回复: 0

R语言:strwrap()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-2-16 17:48:14 | 显示全部楼层 |阅读模式
strwrap(base)
strwrap()所属R语言包:base

                                        Wrap Character Strings to Format Paragraphs
                                         段落格式封装字符串

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Each character string in the input is first split into paragraphs (or lines containing whitespace only).  The paragraphs are then formatted by breaking lines at word boundaries.  The target columns for wrapping lines and the indentation of the first and all subsequent lines of a paragraph can be controlled independently.
首先,在输入每个字符串分割成段(或只包含空格的行)。打破单词边界线的段落,然后格式化。可以独立控制,包装线和首缩进和段落的所有后续行的目标列。


用法----------Usage----------


strwrap(x, width = 0.9 * getOption("width"), indent = 0,
        exdent = 0, prefix = "", simplify = TRUE, initial = prefix)



参数----------Arguments----------

参数:x
a character vector, or an object which can be converted to a character vector by as.character.
一个字符向量,或可转换as.character字符向量的对象。


参数:width
a positive integer giving the target column for wrapping lines in the output.
一个正整数,使包装在输出线的目标列。


参数:indent
a non-negative integer giving the indentation of the first line in a paragraph.
一个非负整数,在一个段落的第一行的缩进。


参数:exdent
a non-negative integer specifying the indentation of subsequent lines in paragraphs.
一个非负整数,指定段的后续行缩进。


参数:prefix, initial
a character string to be used as prefix for each line except the first, for which initial is used.
一个字符串,用来作为前缀的每一行,除了第一,其中initial使用。


参数:simplify
a logical.  If TRUE, the result is a single character vector of line text; otherwise, it is a list of the same length as x the elements of which are character vectors of line text obtained from the corresponding element of x. (Hence, the result in the former case is obtained by unlisting that of the latter.)
一个逻辑。如果TRUE,结果是一个单一行文本的特征向量,否则,它是一个长度相同的列表x其中的元素是行文本的字符获得相应的元素的向量x。 (因此,在前一种情况下的结果得到,由unlisting后者。)


Details

详情----------Details----------

Whitespace (space, tab or newline characters) in the input is destroyed.  Double spaces after periods, question and explanation marks (thought as representing sentence ends) are preserved. Currently, possible sentence ends at line breaks are not considered specially.
输入中的空白(空格,制表符或换行符)被摧毁。期间,问题和解释商标后双位(思想为代表的句子完)将被保留。目前,可能的话,在换行符结束,没有特别的考虑。

Indentation is relative to the number of characters in the prefix string.
缩进是相对的前缀字符串中的字符数。


值----------Value----------

A character vector in the current locale's encoding (if simplify is TRUE), or a list of such character vectors.
一个在当前语言环境的编码字符向量(simplify如果是TRUE),或等特征向量的列表。


举例----------Examples----------


## Read in file 'THANKS'.[#读取文件谢谢。]
x <- paste(readLines(file.path(R.home("doc"), "THANKS")), collapse = "\n")
## Split into paragraphs and remove the first three ones[#段分成和删除,前三]
x <- unlist(strsplit(x, "\n[ \t\n]*\n"))[-(1:3)]
## Join the rest[#加入其余]
x <- paste(x, collapse = "\n\n")
## Now for some fun:[#现在一些有趣的:]
writeLines(strwrap(x, width = 60))
writeLines(strwrap(x, width = 60, indent = 5))
writeLines(strwrap(x, width = 60, exdent = 5))
writeLines(strwrap(x, prefix = "THANKS> "))

## Note that messages are wrapped AT the target column indicated by[#注意,包裹邮件指示目标列]
## 'width' (and not beyond it).[#宽(不超过)。]
## From an R-devel posting by J. Hosking &lt;jh910@juno.com&gt;.[#从R-与开发J.霍斯金<jh910@juno.com>张贴。]
x <- paste(sapply(sample(10, 100, replace=TRUE),
           function(x) substring("aaaaaaaaaa", 1, x)), collapse = " ")
sapply(10:40,
       function(m)
       c(target = m, actual = max(nchar(strwrap(x, m)))))

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-1-23 06:10 , Processed in 0.020941 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表