Skip to content

Instantly share code, notes, and snippets.

@ledell
Created February 15, 2019 19:28
Show Gist options
  • Save ledell/74efb2773a603ea9b3e10bbcfb2ec77b to your computer and use it in GitHub Desktop.
Save ledell/74efb2773a603ea9b3e10bbcfb2ec77b to your computer and use it in GitHub Desktop.
Code for plot of R-Ladies growth featured here: https://twitter.com/ledell/status/1095815376598851584
library("ggplot2")
library("scales")
library("devtools")
install_github("rladies/meetupr", ref = "topic_id")
library("meetupr") #Requires topic_id branch...
api_key = "API_KEY" #Use your own meetup.com API key...
meetups <- find_groups(topic_id = 1513883, api_key = api_key) #all groups tagged with "R-Ladies" topic id
meetups <- meetups[-nrow(meetups), ] #remove Joburg-R-Users-Group
tc <- find_groups(text = "r ladies twin cities", api_key = api_key) #add Twin Cities
tp <- find_groups(text = "r ladies taipei", api_key = api_key) #add Taipei
meetups <- rbind(meetups, tc, tp)
meetups[nrow(meetups), "created"] <- as.Date("2014-08-01") #Fix Taipei date
meetups$Date <- as.POSIXct(meetups$created)
meetups$counts <- rep(1, nrow(meetups))
p <- ggplot(meetups, aes(Date, ..count..)) +
geom_histogram() +
theme_bw(base_size = 14) + xlab(NULL) +
scale_x_datetime(breaks = date_breaks("3 months"),
labels = date_format("%Y-%b"),
limits = c(as.POSIXct("2012-01-01"),
as.POSIXct("2019-03-01")) ) +
geom_vline(xintercept = as.POSIXct("2016-07-01"), col = "purple", size = 2) +
annotate("text", x = as.POSIXct("2015-03-01"), y = 20, label = "Creation of R-Ladies Global Team/Org \n(useR! 2016)",
colour = "purple", size = 5) +
annotate("text", x = as.POSIXct("2012-10-01"), y = 3, label = "San Francisco", colour = "purple", size = 4) +
annotate("text", x = as.POSIXct("2016-01-31"), y = 3, label = "London", colour = "purple", size = 4) +
annotate("text", x = as.POSIXct("2015-04-01"), y = 3, label = "Twin Cities", colour = "purple", size = 4) +
annotate("text", x = as.POSIXct("2014-08-01"), y = 3, label = "Taipei", colour = "purple", size = 4) +
theme(axis.text.x = element_text(angle = 45, hjust = 1))
p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment