Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

separate_rows..html

Separate a collapsed column into multiple rows


Description

If a column contains observations with multiple delimited values, separate them each into their own row.

Usage

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

Arguments

.df

A data.frame or data.table

...

Columns to separate across multiple rows. tidyselect compatible

sep

Separator delimiting collapsed values

convert

If TRUE, runs type.convert() on the resulting column. Useful if the resulting column should be type integer/double.

Examples

test_df <- data.table(
  x = 1:3,
  y = c("a", "d,e,f", "g,h"),
  z = c("1", "2,3,4", "5,6")
)

separate_rows.(test_df, y, z)

separate_rows.(test_df, y, z, convert = TRUE)

tidytable

Tidy Interface to 'data.table'

v0.6.1
MIT + file LICENSE
Authors
Mark Fairbanks [aut, cre], Abdessabour Moutik [ctb], Matt Carlson [ctb], Ivan Leung [ctb], Ross Kennedy [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.