A data frame of the corresponding rows or, if value = FALSE, the
corresponding row numbers.
Arguments
dat
Data frame
pattern
character string containing a regular expression
(or character string for fixed = TRUE) to be matched
in the given character vector. Coerced by
as.character to a character string if possible. If a
character vector of length 2 or more is supplied, the first element
is used with a warning. Missing values are allowed except for
regexpr, gregexpr and regexec.
cols
[character]
Character vector of columns to search.
If NULL (default) all character and factor columns will be searched.
value
[logical]
Should a data frame of rows be returned.
If FALSE (defauly) row indices will be returned instead of the rows
themselves.
ignore.case
if FALSE, the pattern matching is case
sensitive and if TRUE, case is ignored during matching.
perl
logical. Should Perl-compatible regexps be used?
fixed
logical. If TRUE, pattern is a string to be
matched as is. Overrides all conflicting arguments.
invert
logical. If TRUE return indices or values for
elements that do not match.
dat <- data.frame(
first = letters,
second = factor(rev(LETTERS)),
third = "Q")
greprows(dat, "A|b")
greprows(dat, "A|b", ignore.case = TRUE)
greprows(dat, "c", value = FALSE)