美文网首页BG-R
20190506-R语言字符处理函数※grep、grepl

20190506-R语言字符处理函数※grep、grepl

作者: 天空的小白 | 来源:发表于2019-05-06 17:47 被阅读0次

※ grep

Usage
grep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE, fixed = FALSE, useBytes = FALSE, invert = FALSE);
在向量x中寻找含有特定字符串(pattern参数指定)的元素,返回其在x中的下标;
Arguments

  • invert→若设置为TRUE,返回不包含pattern的元素的下标
  • value→若设置为TRUE,返回相应的元素;
    Example
    grep

grepl

Usage
grepl(pattern, x, ignore.case = FALSE, perl = FALSE, fixed = FALSE, useBytes = FALSE)
类似grep,但是返回逻辑向量,即是否包含pattern
Example

grepl返回逻辑值

相关文章

网友评论

    本文标题:20190506-R语言字符处理函数※grep、grepl

    本文链接:https://www.haomeiwen.com/subject/kjeroqtx.html