【发布时间】:2017-09-13 17:52:12
【问题描述】:
所以我已经有一个 TDM,但它在 excel 上。所以我将它保存为 CSV。现在我想做一些分析,但我不能使用 tm 包将它作为 TDM 加载。我的 CSV 看起来像这样:
item01 item02 item03 item04
red 0 1 1 0
circle 1 0 0 1
fame 1 0 0 0
yellow 0 0 1 1
square 1 0 1 0
所以我无法将该文件作为 TDM 加载,到目前为止我尝试过的最好的方法是:
myDTM <- as.DocumentTermMatrix(df, weighting = weightBin)
但它在所有单元格上加载 1
<<DocumentTermMatrix (documents: 2529, terms: 1952)>>
Non-/sparse entries: 4936608/0
Sparsity : 0%
Maximal term length: 27
Weighting : binary (bin)
Sample :
Terms
Docs item01 item02 item03 item04
Red 1 1 1 1
Circle 1 1 1 1
fame 1 1 1 1
我尝试过先转换为 Corpus 和其他东西,但如果我尝试使用像 inspect(tdm) 这样的任何函数,它会返回一个错误,比如这个或类似的。
Error in `[.simple_triplet_matrix`(x, docs, terms) :
我真的不相信没有办法以正确的格式导入它,有什么建议吗?提前致谢。
【问题讨论】:
标签: r csv text-mining text-analysis