Skip to content

Instantly share code, notes, and snippets.

@szilard
Created March 16, 2014 02:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szilard/9577916 to your computer and use it in GitHub Desktop.
Save szilard/9577916 to your computer and use it in GitHub Desktop.
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