Last active
August 29, 2015 13:56
-
-
Save thoolihan/8949169 to your computer and use it in GitHub Desktop.
Facebook Friend Gender Analysis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(rjson) | |
graph <- fromJSON(paste(readLines("friends.json"), collapse="")) | |
gender <- as.factor( | |
sapply(graph$data, function(f) { | |
ifelse(is.null(f$gender), "na", f$gender) | |
}) | |
) | |
barplot(c(all = length(gender), summary(gender)), | |
col = c('green','pink','blue','gray'), | |
ylim = c(0,400), | |
names.arg = c('All','Female','Male','NA'), | |
main = "Facebook Friends By Gender") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment