I have this dataframe to_expand with two columns:
to_expand <- data.frame(first = c('a~b'), second = paste(list(c('1~2~3'), c('4~5~6')), collapse = '|'))
  first       second
1   a~b 1~2~3|4~5~6
How can I turn it to:
# A tibble: 2 x 2
  first second
  <chr> <chr> 
1 a     1~2~3  
2 b     4~5~6
I have tried using sepratate_rows() from tidyr but it gave all the possible combinations between the two columns.
Any help would be much appreciated!
Edit: using separate_rows(second, sep = '\\|') gave me a~b on both rows.
> to_expand %>% separate_rows(second, sep = '\\|')
# A tibble: 2 x 2
  first second
  <chr> <chr> 
1 a~b   1~2~3 
2 a~b   4~5~6 
 
     
     
     
    