greprows | R Documentation |
greprows()
searches for pattern matches within a data frames columns and
returns the related rows or row indices.
grepvrows()
is identical to greprows()
except with the default
value = TRUE
.
greplrows()
returns a logical vector (match or not for each row of dat).
greprows(
dat,
pattern,
cols = NULL,
value = FALSE,
ignore.case = FALSE,
perl = FALSE,
fixed = FALSE,
invert = FALSE
)
greplrows(
dat,
pattern,
cols = NULL,
ignore.case = FALSE,
perl = FALSE,
fixed = FALSE,
invert = FALSE
)
grepvrows(
dat,
pattern,
cols = NULL,
value = TRUE,
ignore.case = FALSE,
perl = FALSE,
fixed = FALSE,
invert = FALSE
)
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 |
A data frame of the corresponding rows or, if value = FALSE
, the
corresponding row numbers.
grep()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.