【发布时间】:2017-02-07 02:40:44
【问题描述】:
我有一个 csv 文件,其中我的所有文档都以术语文档矩阵形式和分类变量作为情感。
我想使用tm 的功能(术语频率等)。鉴于我开始使用的数据,有没有办法做到这一点?
# given:
dtm = read.csv(file_path, na.strings="")
dtm$rating = as.factor(dtm$rating)
str(dtm)
# 'data.frame': 2000 obs. of 2002 variables:
# $ ID : int 1 2 3 4 5 6 7 8 9 10 ...
# $ abl : int 0 0 0 0 0 0 0 0 0 0 ...
# ...
head(dtm)
#ID abl absolut absorb accept
#1 1 0 0 0
#2 2 0 0 1
# I'd like to achieve...
tdm <- TermDocumentMatrix(dtm,
control = list(removePunctuation = TRUE,
stopwords = TRUE))
【问题讨论】:
-
dtm 已经是词频的data.frame 了吗?
标签: r