Analyzing Facebook Networks using #rstats is given below. Note this can be replicated by anyone- and you can theoretically be able to create adjacency matrix (friend of friends) of all people who have given permission into your app- thus maybe a network analysis of people to some group (like R Facebook group https://www.facebook.com/groups/rusers/?fref=ts or even FOASStat https://www.facebook.com/groups/foastat/?fref=ts is possible
While traditional marketing and targeting focusses on variables like demographics and psychographics, social network analysis lets you tap into influential people within communities with the right offer and then let the free retweet, reshare as proxy free ads. The hypothesis being that people in similar network clusters have similar consumer behaviours (not just in similar demographic or psychographics). Also this should ideally be able to capture changing consumer behaviour faster for better targeting.
Sources-
1) Go to
2) Create a new app
https://developers.facebook.com/apps/241634542707615

3) Change url in settings ( to http://localhost:1410 ). I wish we could do this in twitteR package and oAuth for TWitter but I have no clue . that. Also coming up post on Google Plus and LinkedIn (if I can)
https://developers.facebook.com/apps/241634542707615/settings/

3) Copy the secret thingies from the dashboard. DO click the screenshots to enlarge (i.e to understand what I am trying to do here)
https://developers.facebook.com/apps/241634542707615/dashboard/

4) Modify code below with the secret thingies above
install.packages("Rfacebook")
install.packages("httpuv")
library(Rfacebook)
library(httpuv)
#fbOAuth(app_id, app_secret, extended_permissions = TRUE)
fb_oauth=fbOAuth("241634542707615", "4f2e6273c08d1b56d1bf14626d9e19a6", extended_permissions = TRUE)
#fb_oauth <- fbOAuth(app_id="123456789", app_secret="1A2B3C4D")
save(fb_oauth, file="fb_oauth")
getwd()
dir()
Created by Pretty R at inside-R.org
5) Hey now we have a fb ouath object we can just load it up. we the following code can then be modified at will to get your analysis
library(Rfacebook)
library(httpuv)
library(RColorBrewer)
load("fb_oauth")
me <- getUsers("me", token=fb_oauth)
#getFQL(query, token)
my_friends <- getFriends(token=fb_oauth, simplify=F)
str(my_friends)
table(my_friends$relationship_status)
pie(table(my_friends$relationship_status),col=brewer.pal(5, "Set1"))
table(my_friends$location)
pie(table(my_friends$location),col=brewer.pal(20, "Greens"))
pie(table(my_friends$locale),col=brewer.pal(4, "Blues"))
pie(table(my_friends$gender),col=brewer.pal(3, "Oranges"))
load("fb_oauth")
mat <- getNetwork(token=fb_oauth, format="adj.matrix")
library(igraph)
network <- graph.adjacency(mat, mode="undirected")
getwd()
setwd("C:/Users/dell/Desktop")
pdf("network_plot.pdf")
plot(network ,vertex.size=5,
vertex.label=NA,
vertex.label.cex=0.45,
edge.arrow.size=1,
edge.curved=TRUE,)
dev.off()
Created by Pretty R at inside-R.org
6) Voila my FB graph

and analyzed for how are my homies

Europeans into open relationships more

Places my friends are

Languages they speak
and all with R
Note- this is what an adjancency matrix is- just a fancy word for turning your Fb friends into a 1-0 matrix based on their relationships. The more friends you have the more interesting this analysis
Now lets do likes analysis
I use this code and my own username (since I am the only one who has allowed the app permissions!)
likes=getLikes(user="byebyebyer",n=500,token=fb_oauth)
Boy I like a lot of websites huh- I wonder if I can cluster/ data reduce/association analysis them (but that’s coming up or is it?)


Hat tips-
http://thinktostart.wordpress.com/2013/11/19/analyzing-facebook-with-r/
http://blog.revolutionanalytics.com/2013/11/how-to-analyze-you-facebook-friends-network-with-r.html

28.635308
77.224960
Like this:
Like Loading...