%gin%
is a reimagination of %in%
using grepl()
for partial string matching.
Arguments
- pattern
Character string to be matched.
- x
R
object to be matched against. The object must be a character vector or an object coercible byas.character()
to a character vector.
References
%gin%
was first written for @ivelasq's r-data-recipes GitHub repository.
Examples
# %in% evaluates to FALSE because it looks for full string matches
"t" %in% "tonic"
#> [1] FALSE
# %gin% evaluates to TRUE
"t" %gin% "tonic"
#> [1] TRUE
# %gin% can be used with tab()
tab("Toyota" %gin% rownames(mtcars))
#> "Toyota" %gin% rownames(mtcars) │ Freq. Percent Cum.
#> ──────────────────────────────────┼───────────────────────────────────
#> FALSE │ 30 93.8 93.8
#> TRUE │ 2 6.2 100.0
#> ──────────────────────────────────┼───────────────────────────────────
#> Total │ 32 100.0