Monitoring des médias 2
[This article was first published on Learning Data Science , and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Petit monitoring de notre observatoire des médias sur Twitter.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Chez Mediapart :
Le Monde
Le Figaro
Le parisien
Vue globale
Le code pour réaliser ce post :
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")) |
To leave a comment for the author, please follow the link and comment on their blog: Learning Data Science .
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.