這是我第一次進行twitter分析。tm_map在R中出現錯誤
#Search data from Twitter
library("twitteR")
SearchData = searchTwitter("Bruno Mars", n=1000,lang = 'en')
SearchData
#Scrapping Data
userTimeline("BrunoMars", n=100, maxID =NULL, excludeReplies = FALSE, includeRts = FALSE)
class(SearchData)
head(SearchData)
#Cleanning Data
library(NLP)
library(tm)
TweetList <- sapply(SearchData, function(x) x$getText())
TweetList <- (TweetList[!is.na(TweetList)])
TweetCorpus <- Corpus(VectorSource(TweetList))
TweetCorpus <- iconv(TweetCorpus, to ="utf-8")
#change data to lower case
TweetCorpus <- tm_map(TweetCorpus,removePunctuation)
TweetCorpus <- tm_map(TweetCorpus, removeNumbers)
TweetCorpus <- tm_map(TweetCorpus, tolower)
我有這個錯誤「錯誤UseMethod(」 tm_map」,X): 應用於類的一個對象‘tm_map’不適用的方法。‘人物’在我的最後3行
我試圖通過在removePunctuation,removeNumbers和tolower之前添加content_transformer來解決這個問題,但是我仍然有同樣的錯誤,我真的不知道,我需要你的建議和你的建議。發行了幾天,但還沒有解決。
非常感謝 Ros
非常感謝Patronus –