grapes-pm-grapes: Binary Operator for Partial Matches

%pm%R Documentation

Binary Operator for Partial Matches

Description

The binary operator %pm% returns a logical vector indicating if there is a partial match against its left operand (see base::grepl).

Usage

x %pm% y

Arguments

x

A vector of values to be matched.

y

The value to be partially matched against.

Details

This operator is robust against NA, returning TRUE if y equals NA and FALSE otherwise.

Value

A logical vector equal to TRUE for all elements in x that contain y in some form.

Author(s)

Kevin Potter

Examples

x <- c( "Cat", "Dog", "Bat" )
x %pm% "at"

# Can match NA
x[2] <- NA
x %pm% "at"
x %pm% NA


rettopnivek/camrprojects documentation built on March 26, 2024, 9:17 a.m.