Skip to contents

Separate a collapsed column in an ir object into multiple rows

Usage

separate_rows.ir(data, ..., sep = "[^[:alnum:].]+", convert = FALSE)

Arguments

data

An object of class ir.

...

<tidy-select> Columns to separate across multiple rows

sep

Separator delimiting collapsed values.

convert

If TRUE will automatically run type.convert() on the key column. This is useful if the column types are actually numeric, integer, or logical.

Value

data with a collapsed column separated into multiple rows. See tidyr::separate_rows().

Examples

## separate_rows
ir_sample_data %>%
  tidyr::unite(
    col = content, holocellulose, klason_lignin
  ) %>%
  tidyr::separate_rows(
    col
  )
#> # A tibble: 116 × 6
#>    id_measurement id_sample sample_type sample_comment            col   spectra 
#>  *          <int> <chr>     <chr>       <chr>                     <chr> <named >
#>  1              1 GN 11-389 needles     Abies Firma Momi fir      0.30… <tibble>
#>  2              1 GN 11-389 needles     Abies Firma Momi fir      0.35… <tibble>
#>  3              2 GN 11-400 needles     Cupressocyparis leylandi… 0.24… <tibble>
#>  4              2 GN 11-400 needles     Cupressocyparis leylandi… 0.33… <tibble>
#>  5              3 GN 11-407 needles     Juniperus chinensis Chin… 0.33… <tibble>
#>  6              3 GN 11-407 needles     Juniperus chinensis Chin… 0.26… <tibble>
#>  7              4 GN 11-411 needles     Metasequoia glyptostrobo… 0.18… <tibble>
#>  8              4 GN 11-411 needles     Metasequoia glyptostrobo… 0.35… <tibble>
#>  9              5 GN 11-416 needles     Pinus strobus Torulosa    0.30… <tibble>
#> 10              5 GN 11-416 needles     Pinus strobus Torulosa    0.33… <tibble>
#> # … with 106 more rows