Skip to content

Instantly share code, notes, and snippets.

@thoolihan
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thoolihan/8949169 to your computer and use it in GitHub Desktop.
Save thoolihan/8949169 to your computer and use it in GitHub Desktop.
Facebook Friend Gender Analysis
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