我正在使用tm包来计算数据集的term-document-matrix,我现在必须将文档 - 矩阵文字写入文件,但是当我在R中使用写入函数时,出现错误。写一个简单的三元组矩阵到文件?
这里是我使用的代码,我得到的错误:
data("crude")
tdm <- TermDocumentMatrix(crude, control = list(weighting = weightTfIdf, stopwords = TRUE))
dtm <- DocumentTermMatrix(crude, control = list(weighting = weightTfIdf, stopwords = TRUE))
,这是错误,而我用的是write.table命令对这个数据:
Error in cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'list') cannot be handled by 'cat'
我明白tbm是Simple Triplet Matrix类型的对象,但我怎样才能将它写入一个简单的文本文件。
谢谢Tony和Shane!解决方案帮助我度过了美好的时光 – 2010-07-16 04:25:48
我不认为这个工作了,'不能强制类......到data.frame' – wordsforthewise 2018-01-28 07:12:11
@wordsforthewise在Windows 7,R版本3.4.3和tm_0.7-3下适用于我的工作 – 2018-02-01 18:50:03