我在R上有这个数据框:
id value
1 "i want it"
2 "you hate me"
3 " they know"
==>由ID
标识的3条评论现在我想分开评论,但保留每个单词的id:
id word
1 i
1 want
1 it
2 you
2 hate
2 me
3 they
3 Know
我尝试使用split,sapply ...但我不明白我该怎么做。 有人可以帮帮我吗?
感谢您的帮助
答案 0 :(得分:0)
我们可以使用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