匹配:match与%in%操作符

来源:互联网 发布:燃烧学 知乎 编辑:程序博客网 时间:2024/06/09 15:44

match{base}

returns a vector of the positions of (first) matches of its first argument in its second.

 

%in%

is a more intuitive interface as a binary operator, which returns a logical vector indicating if there is a match or not for its left operand.

 

match(x,table,nomatch=NA_integer_,incomparables=NUL)

x %in% table

 

区别:

x %in% table:结果为与x等长的TURE/FALSE向量

match(x,table):结果为与x等长的向量

(1)x[i]在table中未出现,则为NA

(2)x[i]在table中的位序

原创粉丝点击