2017-03-20 3 views
0

を解凍した後、 『create_matrix「エラーの機能を見つけることができませんでした』:!:TMパッケージには、私はRでこのコードを実行しようとすると、私は問題を抱えている

library(RTextTools) 
library(e1071) 

pos_tweets = rbind(
    c('I love this car', 'positive'), 
    c('This view is amazing', 'positive'), 
    c('I feel great this morning', 'positive'), 
    c('I am so excited about the concert', 'positive'), 
    c('He is my best friend', 'positive') 
) 

neg_tweets = rbind(
    c('I do not like this car', 'negative'), 
    c('This view is horrible', 'negative'), 
    c('I feel tired this morning', 'negative'), 
    c('I am not looking forward to the concert', 'negative'), 
    c('He is my enemy', 'negative') 
) 

test_tweets = rbind(
    c('feel happy this morning', 'positive'), 
    c('larry friend', 'positive'), 
    c('not like that man', 'negative'), 
    c('house not great', 'negative'), 
    c('your song annoying', 'negative') 
) 

tweets = rbind(pos_tweets, neg_tweets, test_tweets) 



# build dtm 
matrix= create_matrix(tweets[,1], language="english", 
         removeStopwords=FALSE, removeNumbers=TRUE, 
         stemWords=FALSE) 

が、私はこのエラーを取得する

"Error: could not find function "create_matrix

私はパッケージをインストールする前に、コードは、うまく働いたが、私は、TMパッケージをインストールしたとき、私は今、このエラーが発生します。

任意のアイデアをしてください?

+0

をインストールする必要があります。たとえば、 'pos_tweets'を' cbind(c( '私はこの車が大好きです'、 'This view is amazing'、...)、 'positive ')'と定義します。 –

+0

@KonradRudolphあなたは深刻ですか?私のコードが明確でないことがわかりましたか?奇妙な答え – Datackatlon

+0

いいえ、それはかなり明確です。しかし、それはさらに明確になる可能性があります:まだ多くの繰り返しがあります。値そのものだけでなく、その周囲の文法的なノイズ( 'c(...)'を繰り返す)。 –

答えて

1

まず、あなたは、あなたの定義で繰り返しを避けることによって読み込み(と書き込み)してあなたのコードがずっと簡単にすることができ、「スラム」

#install devtools if you have not installed 
install.packages('devtools') 
library(devtools) 

slam_url <- "https://cran.r-project.org/src/contrib/Archive/slam/slam_0.1-37.tar.gz" 
install_url(slam_url) 
+0

ありがとうありがとう:) – Datackatlon

関連する問題