How to grep a vector and return a single TRUE or FALSE?

前端 未结 4 1644
醉梦人生
醉梦人生 2020-12-14 21:25

Is there a grep function in R that returns TRUE if a pattern is found anywhere in the given character vector and FALSE otherwise?

4条回答
  •  死守一世寂寞
    2020-12-14 21:40

    grepl is what you are looking for

    grepl("is", "This is grepl test")
    [1] TRUE
    grepl("is not", "This is grepl test")
    [1] FALSE
    

提交回复
热议问题