vector contains any case-insensitive grep match
igrepHas(
pattern,
x = NULL,
ignore.case = TRUE,
minCount = 1,
naToBlank = FALSE,
...
)
the grep pattern to use with base::grep()
vector to use in the grep
logical default TRUE, meaning the grep will be performed in case-insensitive mode.
integer minimum number of matches required to return TRUE.
logical whether to convert NA to blank, instead of allowing grep to handle NA values as-is.
logical indicating whether the grep match criteria were met, TRUE indicates the grep pattern was present in minCount or more number of entries.
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.
a <- c("data.frame","data_frame","tibble","tbl");
igrepHas("Data.*Frame", a);
#> [1] TRUE
igrepHas("matrix", a);
#> [1] FALSE