Skip to content

Instantly share code, notes, and snippets.

@ledell
Created December 17, 2020 05:24
Show Gist options
  • Save ledell/3c9fc38983d57d0c3af51ea3fdb71769 to your computer and use it in GitHub Desktop.
Save ledell/3c9fc38983d57d0c3af51ea3fdb71769 to your computer and use it in GitHub Desktop.
Count the number of R-Ladies & WiMLDS meetups since COVID quarantine started
# Count the number of covid meetups for R-Ladies and WiMLDS
library(meetupr)
library(tidyverse)
# Look up all R-Ladies & WiMLDS groups by "topic id" & count the events.
# You can find topic ids for associated tags by querying
# [here](https://secure.meetup.com/meetup_api/console/?path=/find/topics).
# The `topic_id` for topic, "R-Ladies", is 1513883.
# The `topic_id` for topic, "WiMLDS", is 1517030.
meetup_events_by_topic <- function(topic_id, start_date, end_date = Sys.Date()) {
# get all the groups for a topic
groups <- find_groups(topic_id = topic_id)
# use a loop to space out API requests (to get group events)
datalist <- list()
for (i in 1:nrow(groups)) {
cat(sprintf("%i of %i: %s\n", i, nrow(groups), groups$urlname[i]))
Sys.sleep(2)
events <- tryCatch(get_events(urlname = groups$urlname[i],
event_status = "past"),
error = function(e) {
message(paste0("No events for: ", groups$urlname[i]))
})
datalist[[i]] <- events
}
# get all events during time period
events <- bind_rows(datalist)
events <- events %>%
filter(local_date >= start_date) %>%
filter(local_date <= end_date)
return(list(groups = groups, events = events))
}
# feel free to adjust to your local lockdown date
covid_start <- "2020-03-15"
# get all R-Ladies covid meetups
rladies <- meetup_events_by_topic(topic_id = 1513883,
start_date = covid_start)
# get all WiMLDS covid meetups
wimlds <- meetup_events_by_topic(topic_id = 1517030,
start_date = covid_start)
nrow(rladies$events) #542 as of 12/16/2020
nrow(wimlds$events) #251 as of 12/16/2020
@ledell
Copy link
Author

ledell commented Dec 17, 2020

Install the meetupr package from Github as follows:

install.packages("remotes")
remotes::install_github("rladies/meetupr")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment