我正在尝试从我的列表中创建一个数据框:
> stemmoutput
[[1]]
[1] "tanaman" "cabai"
[[2]]
[1] "banget" "hama" "sakit" "tanaman"
[[3]]
[1] "koramil" "nogosari" "melaks" "ecek" "hama" "tanaman" "padi" "ppl" "ds" "rambun"
[[4]]
[1] "tani" "hama" "sakit" "tanaman"
[[5]]
[1] "tani" "hama" "sakit" "tanaman" NA
我在使用data.frame(stemmoutput)
时遇到问题,我不断收到此错误消息。
Error in data.frame(c("tanaman", "cabai"), c("banget", "hama", "sakit", :
arguments imply differing number of rows: 2, 4, 3, 5
答案 0 :(得分:3)
两种合理的方法:
data.frame(word = do.call(c, stemoutput),
group = rep(1:length(stemoutput),
sapply(stemoutput, length)))
require(reshape2)
melt(stemoutput)
它只是组标签。