The operator %w% checks if the string on the left-hand side is contained within the string on the right-hand side.

x %w% y

Arguments

x

A character string.

y

A character vector.

Value

A logical vector, TRUE if x is contained in a given element of y.

Examples

# Check if a string is part of
# another string
"A" %w% "ABC"
#> [1] TRUE
"D" %w% "ABC"
#> [1] FALSE

# Vectorized for y
"A" %w% c("ABC", "DEF", "GHI")
#> [1]  TRUE FALSE FALSE