March 12, 2014

Try the Rfacebook package

Code There are many webAPI to get information from SNS. For example, Twitter, Facebook, Google+…
Today, I try to get information through the Facebook API with Rfacebook package. With the package, you can easily manipulate data through R. Now, Rfacebook package is uploaded to CRAN, so you can download from there.
Before you use the package, you have to take only one step for the preparation. You get the token generated here: With this token, you will be authorized at the Facebook graph API.
Have you got your token? Now you are ready to use the package.
Today I only get network information around me and visualize it. For the visualization, I use the d3Network package. This package can be also downloaded from CRAN. It enables you to make an interactive network plot by d3.js.
Here's the result. Tomorrow, I will try to get other information.


# Get data by Rfacebook
token <- "XXXXXXXXXX"
mat <- getNetwork(token, format = "edgelist", verbose = FALSE)
# Vis by d3Network
d <- data.frame(mat)
d$X1 <- as.numeric(d$X1)  # anonymize
d$X2 <- as.numeric(d$X2)
d3SimpleNetwork(d, iframe = TRUE)

No comments:

Post a Comment