View source: R/dataframe_utilities.R
separate_rows | R Documentation |
Split rows based on a delimited string column
separate_rows(df, col, sep = ", ")
df |
A dataframe |
col |
The column to split on |
sep |
The separator characters |
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.
A dataframe
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.