startsWith_any_of: Tell if a string starts with any of a vector of strings

View source: R/utilities.R

startsWith_any_ofR Documentation

Tell if a string starts with any of a vector of strings

Description

This function returns TRUE if x starts with any of the strings in target and FALSE otherwise.

Usage

startsWith_any_of(x, prefixes)

Arguments

x

a string (or vector or list of strings)

prefixes

a vector or list of strings

Details

This function is vectorized. If x is a vector or list of strings, the return value has the same length as x and contains the result of applying the test (does x start with any of target) for each item in x.

Value

TRUE if x starts with any of the strings in target, FALSE otherwise. If x is a vector or list of strings, the return value is the same length as x and contains the result of applying the test to each item in x.

Examples

startsWith_any_of(x = "prefix - suffix", prefixes = c("a", "b", "prefix"))
startsWith_any_of(x = "prefix - suffix", prefixes = c("a", "b", "c"))
startsWith_any_of(x = "prefix - suffix", prefixes = "suffix")
startsWith_any_of(x = c("Production - Crude", "Production - NG",
                         "Exports - Oil", "Exports - Crude"),
                   prefixes = c("Production", "Imports"))

MatthewHeun/Recca documentation built on Feb. 9, 2024, 6:18 p.m.