R grep regular expression using elements in a vector (FOLLOW UP)

后端 未结 3 1497
被撕碎了的回忆
被撕碎了的回忆 2021-01-26 23:58

Following up on this question, I have another example where I cannot use the accepted answer.

Again, I want to find each of the exact group elements in the

3条回答
  •  忘了有多久
    2021-01-27 00:11

    Try this from the stringr package. The "coll" option implements "human readable collation rules" which helps you match things that look identical, but for some reason, R resists matching them at first:

    > library(stringr)
    > str_detect(labs,coll(groups))
     [1]  TRUE FALSE FALSE  TRUE FALSE  TRUE  TRUE FALSE FALSE  TRUE FALSE  TRUE  
    TRUE FALSE FALSE
    [16]  TRUE FALSE FALSE  TRUE FALSE FALSE  TRUE FALSE FALSE
    

提交回复
热议问题