igrepHas: vector contains any case-insensitive grep match

igrepHasR Documentation

vector contains any case-insensitive grep match

Description

vector contains any case-insensitive grep match

Usage

igrepHas(
  pattern,
  x = NULL,
  ignore.case = TRUE,
  minCount = 1,
  naToBlank = FALSE,
  ...
)

Arguments

pattern

the grep pattern to use with base::grep()

x

vector to use in the grep

ignore.case

logical default TRUE, meaning the grep will be performed in case-insensitive mode.

minCount

integer minimum number of matches required to return TRUE.

naToBlank

logical whether to convert NA to blank, instead of allowing grep to handle NA values as-is.

Details

This function checks the input vector for any elements matching the grep pattern. The grep is performed case-insensitive (igrep). This function is particularly useful when checking function arguments or object class, where the class(a) might return multiple values, or where the name of the class might be slightly different than expected, e.g. data.frame, data_frame, DataFrame.

Value

logical indicating whether the grep match criteria were met, TRUE indicates the grep pattern was present in minCount or more number of entries.

See Also

base::grep()

Other jam grep functions: grepls(), igrepl(), igrep(), provigrep(), unigrep(), unvigrep(), vgrep(), vigrep()

Examples

a <- c("data.frame","data_frame","tibble","tbl");
igrepHas("Data.*Frame", a);
igrepHas("matrix", a);


jmw86069/jamba documentation built on Oct. 9, 2024, 10:52 a.m.