Skip to content

Instantly share code, notes, and snippets.

@jthomasmock
Last active August 4, 2022 13:25
Show Gist options
  • Select an option

  • Save jthomasmock/39b9ea2a899ed662e6b1f267abbca307 to your computer and use it in GitHub Desktop.

Select an option

Save jthomasmock/39b9ea2a899ed662e6b1f267abbca307 to your computer and use it in GitHub Desktop.
Count in-person attendees per talk at RStudio conf.
library(tidyverse)
library(jsonlite)
library(rvest)
raw_json <- fromJSON("https://raw.githubusercontent.com/rstudio/rstudio-conf-2022-program/main/program.json", simplifyVector = FALSE)
raw_df <- raw_json |>
enframe() |>
unnest_wider(value) |>
hoist(talk,
url = "sched_url")
html_df <- raw_df |>
mutate(html = map(url, read_html))
get_attendees <- function(html){
html |>
html_element("#sched-page-event-attendees > h2") |>
html_text() |>
str_extract("[0-9]+") |>
as.integer()
}
attendee_df <- html_df |>
hoist(
talk,
title = "title",
type = "type",
day = "day",
time_slot = "start_local"
) |>
hoist(
session,
session_slug = "slug"
) |>
select(-talk, -session, -speakers) |>
mutate(attendees = map_int(html, get_attendees)) |>
arrange(desc(attendees))
attendee_df
# A tibble: 99 × 9
name url html title type day time_slot session_slug attendees
<chr> <chr> <list> <chr> <chr> <chr> <chr> <chr> <int>
1 applied-machine-learning https://… <xml_dcmn> Good… Keyn… 2022… 09:00 AM applied-mac… 1250
2 collaborate-with-quarto https://… <xml_dcmn> Hell… Keyn… 2022… 09:00 AM collaborate… 1188
3 past-future-shiny https://… <xml_dcmn> The … Keyn… 2022… 04:30 PM past-future… 1160
4 quarto-for-rmarkdown-users https://… <xml_dcmn> Quar… Regu… 2022… 03:20 PM rmarkdown-q… 898
5 new-way-to-build-shiny https://… <xml_dcmn> A ne… Regu… 2022… 01:30 PM shiny-app-d… 741
6 running-shiny-without-server https://… <xml_dcmn> Runn… Regu… 2022… 11:30 AM python 726
7 data-science-training https://… <xml_dcmn> Data… Keyn… 2022… 04:30 PM data-scienc… 662
8 introduction-to-r7 https://… <xml_dcmn> An i… Regu… 2022… 04:00 PM advanced-r 656
9 making-data-pipelines-in-r https://… <xml_dcmn> Maki… Regu… 2022… 01:30 PM data-quality 608
10 r-python-tableau-love-triangle https://… <xml_dcmn> R, P… Regu… 2022… 11:20 AM business-in… 602
# … with 89 more rows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment