# search for a term in twitter
rdmTweets <- searchTwitteR("machine learning", n=500, lang="en")
dtm.control <- list(
tolower = TRUE,
removePunctuation = TRUE,
removeNumbers = TRUE,
removestopWords = TRUE,
stemming = TRUE, # false for sentiment
wordLengths = c(3, "inf"))
# create a dataframe around the results
df <- do.call("rbind", lapply(rdmTweets, as.data.frame))
# Here are the columns
names(df)
# And some example content
head(df,10)
counts = table(df$screenName)
barplot(counts)
# Plot the data as received from Twitter
cc <- subset(counts,counts>1)
barplot(cc,las = 2,cex.names = 0.3)
# the most commonly cited words in the tweets
rdm_texts <- sapply(rdmTweets, function(x) x$getText())
rdm_corpus <- Corpus(VectorSource(rdm_texts))
dtm <- DocumentTermMatrix(rdm_corpus, control = dtm.control) # throws error
次のようにエラーをスローします -
Error in simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms), :
'i, j, v' different lengths
In addition: Warning messages:
1: In mclapply(unname(content(x)), termFreq, control) :
all scheduled cores encountered errors in user code
2: In simple_triplet_matrix(i = i, j = j, v = as.numeric(v), nrow = length(allTerms), :
NAs introduced by coercion
Twitterでキーワードを検索してから、ワードクラウドを作成しようとしています。すべての句読点を削除し、単語を停止し、数字を削除しますが、まだ機能していないようです。
どんな助けでも大歓迎です。