Top Facebook Posts During the US Presidential Debate
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The following data was collected during the Presidential Debate on the 22nd of October by tapping into the Facebook social graph API using R.
The top three posted links during the debate for each candidate are:
Obama-
#3 http://bit.ly/P8MmJ1
Romney-
#1 http://bit.ly/zDdsKf
#2 http://bit.ly/SjFbKx
#3 http://bit.ly/SjJaXv
The top five video (for both candidates) of the debate are:
#1 http://bit.ly/WearzC
#2 http://bit.ly/QTEibe
#3 http://bit.ly/VT9xXE
#4 http://bit.ly/SeIGDJ
#5 http://bit.ly/PcKJV5
The top five shared photos are:
#1 http://on.fb.me/TOTPIY
#2 http://on.fb.me/RYF7m6
#3 http://on.fb.me/QCQLkj
#4 http://on.fb.me/RSkXXv
#5 http://on.fb.me/T7Lr6h
This data was collected by tapping into the facebook API using the following R code (adapted from cloudstat.org) run in a loop :
library(RCurl)
library(RJSONIO)
Result fb.base<-paste("http://graph.facebook.com/search?q=",Facebook,"&limit=10",sep="")
fb.url<-getURL(fb.base)
fb.parse<-fromJSON(fb.url)
return(fb.parse)
}
FBdebate<-function(x){
candidate<-list("Romney","Obama")
for(a in candidate){
fbkeyword fbresult fbdata fbdata.length fbid = facebookers = fbmessage = fbpic = fblink = fbname = fbcaption =
fbdescription = fbicon = fbtype = fbcreated = fbupdated = fblikecount = 0
for (i in 1:fbdata.length){
fbid[i] facebookers[i] fbmessage[i] fbpic[i] fblink[i] fbname[i] fbcaption[i] fbdescription[i] fbicon[i] fbtype[i] fbcreated[i] fbupdated[i]fblikecount[i]
#for(j in 1:fblikecount[i]){ fblikename[i] }
assign(paste0("fbtable.", a),as.data.frame(cbind(fbid, facebookers, fbmessage, fbpic, fblink, fbname, fbcaption, fbdescription, fbicon, fbtype, fbcreated, fbupdated, fblikecount, candidate=a)))
}
debate<-merge(fbtable.Romney,fbtable.Obama, all=TRUE)
debate$fbupdated<-format(as.POSIXct(strptime(as.character(debate$fbupdated), "%Y-%m-%dT%H:%M:%S+0000"), tz="GMT"), tz="America/New_York",usetz=TRUE)
debate$fbcreated<-format(as.POSIXct(strptime(as.character(debate$fbcreated), "%Y-%m-%dT%H:%M:%S+0000"), tz="GMT"), tz="America/New_York",usetz=TRUE)
return(debate)
}
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.