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

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

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

                                        Abbreviate Strings
                                         缩写字符串

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

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

Abbreviate strings to at least minlength characters, such that they remain unique (if they were), unless strict=TRUE.
至少minlength字符,它们保持独特的(如果他们是),除非strict=TRUE缩写字符串。


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


abbreviate(names.arg, minlength = 4, use.classes = TRUE,
           dot = FALSE, strict = FALSE,
           method = c("left.kept", "both.sides"))



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

参数:names.arg
a character vector of names to be abbreviated, or an object to be coerced to a character vector by as.character.
特征向量的名称缩写,或者被强迫as.character字符向量对象。


参数:minlength
the minimum length of the abbreviations.
最小长度的缩写。


参数:use.classes
logical (currently ignored by R).
逻辑(目前由R忽略不计)。


参数:dot
logical: should a dot (".") be appended?
逻辑:一个点(".")被追加?


参数:strict
logical: should minlength be observed strictly? Note that setting strict=TRUE may return non-unique strings.
逻辑:应minlength严格遵守?请注意,设置strict=TRUE可能返回非唯一的字符串。


参数:method
a string specifying the method used with default "left.kept", see "Details" below.
一个字符串,指定默认的"left.kept"使用的方法,看到下面的“详细资料”。


Details

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

The algorithm (method = "left.kept") used is similar to that of S.  For a single string it works as follows. First all spaces at the beginning of the string are stripped. Then (if necessary) any other spaces are stripped. Next, lower case vowels are removed (starting at the right) followed by lower case consonants. Finally if the abbreviation is still longer than minlength upper case letters are stripped.
使用该算法(method = "left.kept")是类似S的一个单一的字符串,它的工作原理如下。首先在字符串的开头的空格都被剥夺。 (如有必要),然后任何其他空间被剥离。其次,较低的情况下元音被删除(右起),其次是较低的情况下辅音。最后,如果缩写仍然是比minlength大写字母被剥离。

Characters are always stripped from the end of the word first. If an element of names.arg contains more than one word (words are separated by space) then at least one letter from each word will be retained.
字符总是首先从单词的末尾剥离。如果names.arg元素包含多个字(词之间用空格分隔)然后从每个字至少有一个信将被保留。

Missing (NA) values are unaltered.
失踪(NA)值是不变的。

If use.classes is FALSE then the only distinction is to be between letters and space.  This has NOT been implemented.
如果use.classes是FALSE那么唯一的区别是字母和空间之间。这并没有得到落实。


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

A character vector containing abbreviations for the strings in its first argument.  Duplicates in the original names.arg will be given identical abbreviations.  If any non-duplicated elements have the same minlength abbreviations then, if method =   "both.sides" the basic internal abbreviate() algorithm is applied to the characterwise reversed strings; if there are still duplicated abbreviations and if strict=FALSE as by default, minlength is incremented by one and new abbreviations are found for those elements only.  This process is repeated until all unique elements of names.arg have unique abbreviations.
一个特征向量,包含在其第一个参数字符串的缩写。在原有的names.arg重复将给予相同的缩写。如果有任何非重复元素具有相同的minlength然后缩写,如果method =   "both.sides"的基本内部abbreviate()算法应用于逆转字符串的字符;如果有仍然重复的缩写,如果strict=FALSE默认情况下,minlength增加一个新的缩写只发现这些元素。这个过程反复直到names.arg独特元素,具有独特的缩写。

The character version of names.arg is attached to the returned value as a names argument: no other attributes are retained.
names.arg版本返回值作为参数名:没有其他属性保留。


警告----------Warning----------

This is really only suitable for English, and does not work correctly with non-ASCII characters in multibyte locales.  It will warn if used with non-ASCII characters.
这是真的只适合英语,不正确使用多字节语言环境中的非ASCII字符。它会发出警告,如果使用非ASCII字符。


参见----------See Also----------

substr.
substr。


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


x <- c("abcd", "efgh", "abce")
abbreviate(x, 2)
abbreviate(x, 2, strict=TRUE)# &gt;&gt; 1st and 3rd are == "ab"[>>第一和第三的==“AB”]

(st.abb <- abbreviate(state.name, 2))
table(nchar(st.abb))# out of 50, 3 need 4 letters :[50,3需要4个字母:]
as <- abbreviate(state.name, 3, strict=TRUE)
as[which(as == "Mss")]

## method="both.sides" helps:  no 4-letters, and only 4 3-letters:[#方法=“both.sides”帮助:无4字母,只有4 3字母:]
st.ab2 <- abbreviate(state.name, 2, method="both")
table(nchar(st.ab2))
## Compare the two methods:[#比较两种方法:]
cbind(st.abb, st.ab2)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-1-23 12:04 , Processed in 0.020251 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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