Created
May 6, 2013 10:39
-
-
Save Guibrich/5524398 to your computer and use it in GitHub Desktop.
This file contains 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
mediapart<-userTimeline(user="mediapart", | |
n=500,cainfo="cacert.pem") | |
lemonde<-userTimeline(user="lemondefr", | |
n=500,cainfo="cacert.pem") | |
lefigaro<-userTimeline(user="Le_Figaro", | |
n=500,cainfo="cacert.pem") | |
leparisien<-userTimeline(user="le_Parisien", | |
n=500,cainfo="cacert.pem") | |
#Concaténation | |
Media.df<-rbind(mediapart.df, | |
lemonde.df, | |
lefigaro.df, | |
leparisien.df) | |
# Les mots les plus utilisés | |
mots <- strsplit(mediapart.df$text, " ") | |
numb = as.character(seq(1,1000,1)) | |
sw<- c("a",stopwords("fr"),numb) | |
mots <- lapply(mots, function(x) x[grep("^[A-Za-z0-9]+$", x)]) | |
mots <- unlist(mots) | |
mots <- tolower(mots) | |
# Réaliser son wordcloud | |
mots <- mots[!mots %in% sw] | |
mots.t <- as.data.frame(table(mots)) | |
mots.t <- mots.t[sort.list(mots.t$Freq, decreasing = T),] | |
pal <- brewer.pal(8, "Dark2") | |
par(bg = "black") | |
wordcloud(mots.t$mots,mots.t$Freq, scale=c(6,0.7), min.freq=1, max.words=Inf, | |
random.order=F, rot.per=0.25, colors=pal, vfont=c("sans serif","plain")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment