0
我有一個問題,當我嘗試有R運行這段代碼:「錯誤:無法找到函數‘create_matrix’後TM包解壓
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封裝現在我得到這個錯誤。
任何想法嗎?
你可以通過避免你的定義重複來讓你的代碼更容易閱讀(和寫)。例如,將'pos_tweets'定義爲'cbind(c('我喜歡這輛車','這個視圖很棒',...),'正面')''。 –
@KonradRudolph你是認真的?你發現我的代碼不清楚?!奇怪的答案 – Datackatlon
不,這很清楚。但它可能更加清晰:仍然有很多重複;不僅僅是數值本身,還有它周圍的句法噪聲(重複'c(...)')。 –