extract

From tidyr v0.1
0th

Percentile

Extract one column into multiple columns.

Given a regular expression with capturing groups, extract() turns each group into a new column.

Usage
extract(data, col, into, regex = "([[:alnum:]]+)", remove = TRUE,
  convert = FALSE, ...)
Arguments
col
Bare column name.
data
A data frame.
into
Names of new variables to create as character vector.
regex
a regular expression used to extract the desired values.
remove
If TRUE, remove input column from output data frame.
convert
If TRUE, will run type.convert with as.is = TRUE on new columns. This is useful if the component columns are integer, numeric or logical.
...
Other arguments passed on to regexec to control how the regular expression is processed.
Aliases
  • extract
Examples
library(dplyr)
df <- data.frame(x = c("a.b", "a.d", "b.c"))
df %>% extract(x, "A")
df %>% extract(x, c("A", "B"), "([[:alnum:]]+)\\.([[:alnum:]]+)")
Documentation reproduced from package tidyr, version 0.1, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.