Learn R Programming

ir (version 0.4.1)

extract.ir: Extract a character column in an ir object into multiple columns using regular expression groups

Description

Extract a character column in an ir object into multiple columns using regular expression groups

Usage

extract.ir(
  data,
  col,
  into,
  regex = "([[:alnum:]]+)",
  remove = TRUE,
  convert = FALSE,
  ...
)

Value

data with an extracted character column. See tidyr::extract().

Arguments

data

An object of class ir.

col

<tidy-select> Column to expand.

into

Names of new variables to create as character vector. Use NA to omit the variable in the output.

regex

A string representing a regular expression used to extract the desired values. There should be one group (defined by ()) for each element of into.

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.

NB: this will cause string "NA"s to be converted to NAs.

...

Additional arguments passed on to methods.

See Also

Other tidyverse: arrange.ir(), distinct.ir(), filter-joins, filter.ir(), group_by, mutate, mutate-joins, nest, pivot_longer.ir(), pivot_wider.ir(), rename, rowwise.ir(), select.ir(), separate.ir(), separate_rows.ir(), slice, summarize, unite.ir()

Examples

Run this code
## extract
ir_sample_data |>
  tidyr::extract(
    id_sample,  "a"
  )


Run the code above in your browser using DataLab