Strongly typed wrappers around grep that have the
fixed and ignore.case arguments set internally.
Usage
grepf(pattern, x, value = FALSE, useBytes = FALSE, invert = FALSE)
grepi(
pattern,
x,
perl = FALSE,
value = FALSE,
useBytes = FALSE,
invert = FALSE
)Arguments
- pattern
character string containing a regular expression (or character string for
fixed = TRUEto be matched in the given character vector. Coerced by as.character to a character string if possible. If a character vector of length2or more is supplied, the first element is used with a warning. Missing values are allowed.- x
a character vector where matches are sought, or an object which can be coerced by as.character to a character vector. Long vectors are supported.
- value
logical. If
FALSE, a vector containing the (integer) indices of the matches determined by grep is returned, and ifTRUE, a vector containing the matching elements themselves is returned.- useBytes
logical. If
TRUEthe matching is done byte-by-byte rather than character-by-character.- invert
logical. If
TRUEreturn indices or values for elements that do not match.- perl
logical. Should Perl-compatible regexps be used?
Value
with value = FALSE, return a vector of the
indices of the elements of x that yielded a match (or not,
for invert = TRUE). This will be an integer vector unless
the input is a long vector, when it will be a double vector.
with value = TRUE, return a character vector containing the
selected elements of x (after coercion, preserving names but
no other attributes).
Details
*f() suffixed functions have fixed = TRUE and conflicting
arguments (perl and ignore.case) set as FALSE.
*i() suffixed functions have ignore.case = TRUE and the
conflicting fixed argument set as FALSE.
For full documentation of the wrapped functions, see the help
pages for grep.
See also
Other pattern-match-replacement-wrappers:
grepl-wrappers,
grepv-wrappers,
sub-wrappers
