-1

Sorry if the title is a bit misleading. Heres my problem;

I have dataframe with 3 columns

col1      col2      col3
Parta     3         xxx,yyy,zzz
Partb     4         aaa,bbb,ccc

I'd like to stringsplit col3 so that i get the contents in a new column but still maninatin the relationship to the other columns.. like this

col1     col2     col3
Parta    3        xxx
Parta    3        yyy
Parta    3        zzz
Partb    4        aaa
Partb    4        bbb
Partc    4        ccc

Simply I'm sure but I'm struggling...help appreciated.. Paul.

PaulBeales
  • 475
  • 1
  • 8
  • 21

1 Answers1

0

We can use separate_rows from tidyr

library(tidyr)
separate_rows(df1, col3)
akrun
  • 874,273
  • 37
  • 540
  • 662