2017-02-07 6 views
1

私はcsvファイルを持っています。私は、すべての文書をTerm Document Matrixフォームとカテゴリ変数をセンチメントとして持っています。 tmの機能(用語の頻度など)を使用したいと思います。私が始めたデータを考えれば、そうする方法はありますか?Term Document MatrixをTerm Libraryに変換する。

# 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)) 
+0

はすでにdtmです。用語頻度のdata.frameですか? – Jean

答えて

1

あなたが求めるものを行うために(Rパッケージtmで)as.TermDocumentMatrix(df, weighting = weightTf)を使用することはできますか?

関連する問題