Separate a collapsed column in an ir object into multiple rows
Source: R/tidyverse.R
separate_rows.ir.RdSeparate a collapsed column in an ir object into multiple rows
Arguments
- data
An object of class
ir.- ...
<
tidy-select> Columns to separate across multiple rows- sep
Separator delimiting collapsed values.
- convert
If
TRUEwill automatically runtype.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().
See also
Other tidyverse:
arrange.ir(),
distinct.ir(),
extract.ir(),
filter-joins,
filter.ir(),
group_by,
mutate,
mutate-joins,
nest,
pivot_longer.ir(),
pivot_wider.ir(),
rename,
rowwise.ir(),
select.ir(),
separate.ir(),
slice,
summarize,
unite.ir()
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>
#> # ℹ 106 more rows