#PDFTribute: Knowledge is free!
En honor a Aaron Swartz,y gracias al mundo R, (1, 2, 3)
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(twitteR) | |
#Post antiguo, cambió el comando | |
pdftribute2 <- searchTwitter('#pdftribute', n=1500) | |
df_pdf <- do.call("rbind", lapply(pdftribute2, as.data.frame)) | |
names(df_pdf) head(df_pdf,3) | |
df_pdf$text=sapply(df_pdf$text,function(row) iconv(row,to='UTF-8')) | |
trim <- function (x) sub('@','',x) library(stringr) | |
df_pdf$to=sapply(df_pdf$text,function(tweet) | |
str_extract(tweet,"^(@[[:alnum:]_]*)")) | |
df_pdf$to=sapply(df_pdf$to,function(name), trim(name)) | |
df_pdf$rt=sapply(df_pdf$text,function(tweet) trim(str_match(tweet,"^RT (@[[:alnum:]_]*)")[2])) | |
require(ggplot2) attach(df_pdf) names(df_pdf) | |
p1<-ggplot(df_pdf, aes(x=na.omit(factor(rt)))) | |
p1+ geom_bar(fill= "#56B4E9", colour="black") + coord_flip() +opts(axis.text.x=theme_text(angle=-90,size=15))+xlab(NULL) + opts(title="First 1500 #pdftribute's RTs", plot.title = theme_text(face="bold", size=14),axis.text.y=theme_text(size=15), axis.title.x = theme_text(face="bold", size=8)) |
El conocimiento es libre
Comentarios
Publicar un comentario