Created
March 16, 2014 02:56
-
-
Save szilard/9577916 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(RJSONIO) | |
library(httr) | |
library(ggplot2) | |
api_key <- scan("~/.meetup.apikey", character(), quiet = TRUE) | |
group_id <- 1414043 ## LA R meetup | |
req_url <- paste0("http://www.meetup.com/2/events?key=", api_key, | |
"&group_id=",group_id,"&status=past") | |
events_data <- fromJSON(rawToChar(GET(req_url)$content))$results | |
d <- do.call("rbind",lapply(events_data, function(x) | |
data.frame(id = x$id, | |
tm = as.Date(format(as.POSIXct(x$time/1000, origin = "1970-01-01"),"%Y-%m-%d")), | |
venue = if(is.null(x$venue)) NA else x$venue$name, | |
name = x$name, attend = x$yes_rsvp_count, wait = x$waitlist_count, | |
stringsAsFactors = FALSE))) | |
d <- subset(d, attend>17) ## eliminate cross posting | |
d$venue <- sapply(strsplit(gsub("^ *","",d$venue)," "),`[[`,1) | |
d$venue <- ifelse(is.na(d$venue),"other",d$venue) | |
ggplot(d) + geom_line(aes(x = tm, y = attend, ymin = 0), color = "grey70") + | |
geom_point(aes(x = tm, y = attend, color = venue), size = 3) + | |
xlab(NULL) + ylab("attending / waiting list") + | |
geom_step(aes(x = tm, y = wait), direction = "vh", color = "#cc0000") + | |
ggtitle("5 years of LA R meetups") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment