0

I have this data frame on R :

id   value
1    "i want it"
2    "you hate me"
3    " they know"

==>3 comments identified by id

Now i'ld like to split comments, but keeping id for each word:

id   word
1    i
1    want
1    it
2    you
2    hate
2    me
3    they
3    Know

I tried using split, sapply... but i dont see how can i do it. Someone can help me?

Thx for your help

Sotos
  • 51,121
  • 6
  • 32
  • 66
Lolo
  • 1

1 Answers1

0

We can use cSplit

library(splitstackshape)
cSplit(df1, 'value', sep=" ", "long")
#   id value
#1:  1     i
#2:  1  want
#3:  1    it
#4:  2   you
#5:  2  hate
#6:  2    me
#7:  3  they
#8:  3  know
akrun
  • 874,273
  • 37
  • 540
  • 662