greprows {ympes} | R Documentation |
Pattern matching on data frame rows
Description
greprows()
searches for pattern matches within a data frames columns and
returns the related rows or row indices.
Usage
greprows(
dat,
pattern,
cols = NULL,
value = TRUE,
ignore.case = FALSE,
perl = FALSE,
fixed = FALSE,
invert = FALSE
)
Arguments
dat |
Data frame |
pattern |
character string containing a regular expression
(or character string for |
cols |
Character vector of columns to search. If |
value |
Should a data frame of rows be returned. If |
ignore.case |
if |
perl |
logical. Should Perl-compatible regexps be used? |
fixed |
logical. If |
invert |
logical. If |
Value
A data frame of the corresponding rows or, if value = FALSE
, the
corresponding row numbers.
See Also
Examples
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)