R/extract.R
extract.RdGiven a regular expression with capturing groups, extract() turns
each group into a new column. If the groups don't match, or the input
is NA, the output will be NA.
extract(data, col, into, regex = "([[:alnum:]]+)", remove = TRUE, convert = FALSE, ...)
| data | A data frame. |
|---|---|
| col | Column name or position. This is passed to
This argument is passed by expression and supports quasiquotation (you can unquote column names or column positions). |
| into | Names of new variables to create as character vector.
Use |
| regex | a regular expression used to extract the desired values.
There should be one group (defined by |
| remove | If |
| convert | If NB: this will cause string |
| ... | Additional arguments passed on to methods. |
separate() to split up by a separator.
#> A #> 1 <NA> #> 2 a #> 3 a #> 4 b #> 5 d#> A B #> 1 <NA> <NA> #> 2 a b #> 3 a d #> 4 b c #> 5 d e#> A B #> 1 <NA> <NA> #> 2 a b #> 3 a d #> 4 b c #> 5 <NA> <NA>