grab_match {textshape} | R Documentation |
Get Elements Matching Between 2 Points
Description
Use regexes to get all the elements between two points.
Usage
grab_match(x, from = NULL, to = NULL, from.n = 1, to.n = 1, ...)
## S3 method for class 'character'
grab_match(x, from = NULL, to = NULL, from.n = 1, to.n = 1, ...)
## S3 method for class 'list'
grab_match(x, from = NULL, to = NULL, from.n = 1, to.n = 1, ...)
## S3 method for class 'data.frame'
grab_match(
x,
from = NULL,
to = NULL,
from.n = 1,
to.n = 1,
text.var = TRUE,
...
)
Arguments
x |
A character vector, |
from |
A regex to start getting from (if |
to |
A regex to get up to (if |
from.n |
If more than one element matches |
to.n |
If more than one element matches |
text.var |
The name of the text variable with matches. If |
... |
Other arguments passed to |
Value
Returns a subset of the original data set.
Examples
grab_match(DATA$state, from = 'dumb', to = 'liar')
grab_match(DATA$state, from = 'dumb')
grab_match(DATA$state, to = 'liar')
grab_match(DATA$state, from = 'no', to = 'the', ignore.case = TRUE)
grab_match(DATA$state, from = 'no', to = 'the', ignore.case = TRUE,
from.n = 'first', to.n = 'last')
grab_match(as.list(DATA$state), from = 'dumb', to = 'liar')
## Data.frame: attempts to find text.var
grab_match(DATA, from = 'dumb', to = 'liar')