pmatch(base)
pmatch()所属R语言包:base
Partial String Matching
部分字符串匹配
译者:生物统计家园网 机器人LoveR
描述----------Description----------
pmatch seeks matches for the elements of its first argument among those of its second.
pmatch寻求其第一个参数在其第二要素的匹配。
用法----------Usage----------
pmatch(x, table, nomatch = NA_integer_, duplicates.ok = FALSE)
参数----------Arguments----------
参数:x
the values to be matched: converted to a character vector by as.character.
要匹配的值:转换为一个字符向量as.character。
参数:table
the values to be matched against: converted to a character vector.
匹配值:转换为一个字符向量。
参数:nomatch
the value to be returned at non-matching or multiply partially matching positions. Note that it is coerced to integer.
要返回的值不匹配或乘法部分匹配的职位。请注意这是强迫integer。
参数:duplicates.ok
should elements be in table be used more than once?
元素应该是table使用超过一次?
Details
详情----------Details----------
The behaviour differs by the value of duplicates.ok. Consider first the case if this is true. First exact matches are considered, and the positions of the first exact matches are recorded. Then unique partial matches are considered, and if found recorded. (A partial match occurs if the whole of the element of x matches the beginning of the element of table.) Finally, all remaining elements of x are regarded as unmatched. In addition, an empty string can match nothing, not even an exact match to an empty string. This is the appropriate behaviour for partial matching of character indices, for example.
该行为不同于由duplicates.ok的价值。首先考虑的情况下,如果这是真的。第一个被认为是精确匹配,记录的第一个精确匹配的位置。然后被视为独特的部分匹配,如果发现记录。 (部分匹配时,如果整个x元素的table的元素相匹配的开始。)最后,所有剩余的元素x被视为无与伦比的。此外,一个空字符串可以什么都没有,甚至完全匹配匹配一个空字符串。这是适当的行为,例如部分匹配的字符索引。
If duplicates.ok is FALSE, values of table once matched are excluded from the search for subsequent matches. This behaviour is equivalent to the R algorithm for argument matching, except for the consideration of empty strings (which in argument matching are matched after exact and partial matching to any remaining arguments).
duplicates.ok如果是FALSE值table一次匹配,从搜索,为随后的比赛中排除。这种行为是等价的参数匹配的一种算法,除了考虑空字符串(准确和部分匹配任何剩余的参数匹配参数匹配)。
charmatch is similar to pmatch with duplicates.ok true, the differences being that it differentiates between no match and an ambiguous partial match, it does match empty strings, and it does not allow multiple exact matches.
charmatch是pmatch与duplicates.ok真实的,区别只在于,它之间的不匹配和一个含糊不清的部分匹配的区别,它不匹配空字符串,它不允许多个精确匹配。
NA values are treated as if they were the string constant "NA".
NA值视为它们是字符串常量"NA"。
值----------Value----------
An integer vector (possibly including NA if nomatch = NA) of the same length as x, giving the indices of the elements in table which matched, or nomatch.
一个整数向量(可能包括NA如果nomatch = NA)长度相同x,给人的table匹配,或nomatch的元素的索引。
参考文献----------References----------
The New S Language. Wadsworth & Brooks/Cole.
Programming with Data. A Guide to the S Language. Springer.
参见----------See Also----------
match, charmatch and match.arg, match.fun, match.call, for function argument matching etc., grep etc for more general (regexp) matching of strings.
match,charmatch和match.arg,match.fun,match.call,函数的参数匹配等,grep等更普遍的(正则表达式)匹配字符串。
举例----------Examples----------
pmatch("", "") # returns NA[返回不适用]
pmatch("m", c("mean", "median", "mode")) # returns NA[返回不适用]
pmatch("med", c("mean", "median", "mode")) # returns 2[返回2]
pmatch(c("", "ab", "ab"), c("abc", "ab"), dup=FALSE)
pmatch(c("", "ab", "ab"), c("abc", "ab"), dup=TRUE)
## compare[#比较]
charmatch(c("", "ab", "ab"), c("abc", "ab"))
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|