Created
August 4, 2013 14:02
-
-
Save renatocantarino/6150417 to your computer and use it in GitHub Desktop.
Gerador de Cloud Tag em R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("ROAuth") | |
library("twitteR") | |
library("wordcloud") | |
library("tm") | |
options(RCurlOptions = list(capath = system.file("CurlSSL", "cacert.pem", package = "RCurl"), ssl.verifypeer = FALSE)) | |
reqURL <- "https://api.twitter.com/oauth/request_token" | |
accessURL <- "https://api.twitter.com/oauth/access_token" | |
authURL <- "https://api.twitter.com/oauth/authorize" | |
consumerKey <- "Seu Consumer KEY" | |
consumerSecret <- "Hseu Consumer Secret" | |
twitCred <- OAuthFactory$new(consumerKey=consumerKey, | |
consumerSecret=consumerSecret, | |
requestURL=reqURL, | |
accessURL=accessURL, | |
authURL=authURL) | |
twitCred$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl") ) | |
registerTwitterOAuth(twitCred) | |
#the cainfo parameter is necessary on Windows | |
r_stats<- searchTwitter("#soudev", n=500, cainfo="cacert.pem") | |
#save text | |
r_stats_text <- sapply(r_stats, function(x) x$getText()) | |
#create corpus | |
r_stats_text_corpus <- Corpus(VectorSource(r_stats_text)) | |
#clean up | |
r_stats_text_corpus <- tm_map(r_stats_text_corpus, tolower) | |
r_stats_text_corpus <- tm_map(r_stats_text_corpus, removePunctuation) | |
r_stats_text_corpus <- tm_map(r_stats_text_corpus, function(x)removeWords(x,stopwords())) | |
wordcloud(r_stats_text_corpus) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment