Description Usage Arguments Details See Also Examples
These functions provide simple extensions to base regular expressions in R, primarily intended to assist with extraction of elements based on the result of a regular expression evaluation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | ngrep(pattern, x, ignore.case = FALSE, perl = FALSE, value = FALSE,
fixed = FALSE, useBytes = FALSE)
fgrep(pattern, x, ignore.case = FALSE, value = FALSE, useBytes = FALSE,
invert = FALSE)
re_exists(x, pattern, perl = TRUE, fixed = FALSE, ...)
re.exists(pattern, x, perl = TRUE, fixed = FALSE, ...)
re_extract(x, pattern, perl = TRUE, fixed = FALSE, ...)
extract.re(x, pattern, perl = TRUE, fixed = FALSE, ...)
re_without(x, pattern, perl = TRUE, fixed = FALSE, ...)
without.re(x, pattern, perl = TRUE, fixed = FALSE, ...)
re_extract_rows(x, pattern, match_var = rownames(x), perl = TRUE,
fixed = FALSE, ...)
extract_rows.re(x, pattern, match_var = rownames(x), perl = TRUE,
fixed = FALSE, ...)
re_without_rows(x, pattern, match_var = rownames(x), perl = TRUE,
fixed = FALSE, ...)
without_rows.re(x, pattern, match_var = rownames(x), perl = TRUE,
fixed = FALSE, ...)
|
x |
An R object (in the case of |
pattern |
character string containing a character
string to be matched in the given character vector;
coerced by |
ignore.case |
boolean; if |
perl |
boolean; if |
value |
boolean; if |
fixed |
boolean; if |
useBytes |
boolean; if |
match_var |
A variable to match on, as used in the
|
invert |
Invert the results of the regular expression match? |
... |
Optional arguments passed to |
The order is reversed for the re_
set of
functions; i.e., an R object is expected first, rather
than a regular expression pattern.
1 2 3 4 5 6 7 8 9 10 | ngrep( "abc", c("abc", "babcd", "abcdef", "apple"), value=TRUE )
if( re_exists(c("apple", "banana"), "^ap") ) print("yay!")
dat <- data.frame( x=letters, y=LETTERS )
rownames(dat) <- 1:26
## get all rows in dat with a 1, 2, 3 or 4 in the name
re_extract_rows( dat, "[1-4]" )
dat <- data.frame( x=letters, y=LETTERS )
rownames(dat) <- 1:26
## get all rows in dat with a 1, 2, 3 or 4 in the name
re_without_rows( dat, "[0-4]" )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.