grapes-IN-grapes: String in text (vectorised)

Description Usage Arguments Value Author(s) Examples

Description

A Python-style String in Text operator that ignores case. Shorthand for str_detect(str, regex(q, ignore_case = TRUE)). Either q or str must be a single value. The return is a logical value or vector if vectorised input is provided.

Usage

1
q %IN% str

Arguments

q

Regex pattern or vector of patterns to match against str

str

Character value or vector to match q against

Value

A logical value or vector

Author(s)

Robin Edwards

Examples

1
2
3
4
5
6
7
8
'cat' %IN% "The Cat in a Hat"
c('cat', 'fox') %IN% "The Cat in a Hat"
'cat' %IN% c('The Cat in a Hat', 'Fox in Socks')

require(dplyr)
d = starwars %>% select(name) %>% as.data.frame()
d %>% filter('sky' %IN% name)
d %>% filter('[0-9]' %IN% name) # regex

geotheory/textools documentation built on Aug. 17, 2021, 1:18 p.m.