我有一个列形式的数据框 - 输入
Id Comment
xc545 Ronald is a great person
g6548 Hero worship is bad
Run Code Online (Sandbox Code Playgroud)
我需要以Result的形式输出
Id Words
xc545 Ronald
xc545 is
xc545 a
xc545 great
xc545 person
g6548 Hero
g6548 worship
g6548 is
g6548 bad
Run Code Online (Sandbox Code Playgroud)
需要一个R语句来执行此操作.
以下是我试过的 -
result<-lapply(input,function(x)strsplit(x[2]," "))
Run Code Online (Sandbox Code Playgroud)
但是,这只返回一条记录.
r ×1