separate_rows: Split rows based on a delimited string column

View source: R/dataframe_utilities.R

separate_rowsR Documentation

Split rows based on a delimited string column

Description

Split rows based on a delimited string column

Usage

separate_rows(df, col, sep = ", ")

Arguments

df

A dataframe

col

The column to split on

sep

The separator characters

Details

This function splits a dataframe's rows based on delimited values in a column. For instance, a row named "Children" with "Tommy, Gillian, Betsy" would be duplicated three times with the children listed separately on each row.

Value

A dataframe

Examples

library(dplyr)
data_frame(Parent=c("Homer, Marge", "Lorelai", "Peter, Lois"), Child=c("Bart, Lisa, Maggie",
"Rory", "Chris, Meg, Stewey")) %>% separate_rows("Parent") %>% separate_rows("Child")

qPharmetra/PMDatR documentation built on April 7, 2024, 5:42 p.m.