Top Facebook Posts During the US Presidential Debate

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-

#1     http://bit.ly/QCODJg

#2     http://bit.ly/RXstnm

#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)
}

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s