Difference between revisions of "Facebook and R"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) |
PeterHarding (talk | contribs) |
||
Line 18: | Line 18: | ||
<pre> | <pre> | ||
my_friends <- getFriends(token, simplify = TRUE) | |||
head(my_friends$id, n = 1) # get lowest user ID | |||
</pre> | |||
<pre> | |||
my_friends_info <- getUsers(my_friends$id, token, private_info = TRUE) | |||
table(my_friends_info$gender) # gender | |||
</pre> | |||
<pre> | |||
table(substr(my_friends_info$locale, 1, 2)) # language | |||
table(substr(my_friends_info$locale, 4, 5)) # country | |||
table(my_friends_info$relationship_status)["It's complicated"] # relationship status | |||
</pre> | |||
<pre> | |||
mat <- getNetwork(token, format = "adj.matrix") | |||
dim(mat) | |||
</pre> | |||
See - http://blog.revolutionanalytics.com/2013/11/how-to-analyze-you-facebook-friends-network-with-r.html | |||
<pre> | |||
</pre> | </pre> | ||
[[Category:R]] | [[Category:R]] |
Revision as of 15:22, 9 August 2016
Also see - Getting Started with R
install.packages("Rfacebook") # from CRAN library(devtools) install_github("Rfacebook", "pablobarbera", subdir = "Rfacebook") # from GitHub
library(Rfacebook) # token generated here: https://developers.facebook.com/tools/explorer token <- "XXXXXXXXXXXXXX" me <- getUsers("xxxx", token, private_info = TRUE) me$name # my name
my_friends <- getFriends(token, simplify = TRUE) head(my_friends$id, n = 1) # get lowest user ID
my_friends_info <- getUsers(my_friends$id, token, private_info = TRUE) table(my_friends_info$gender) # gender
table(substr(my_friends_info$locale, 1, 2)) # language table(substr(my_friends_info$locale, 4, 5)) # country table(my_friends_info$relationship_status)["It's complicated"] # relationship status
mat <- getNetwork(token, format = "adj.matrix") dim(mat)
See - http://blog.revolutionanalytics.com/2013/11/how-to-analyze-you-facebook-friends-network-with-r.html