Skip to content

Instantly share code, notes, and snippets.

@iangow
Created July 3, 2024 15:19
Show Gist options
  • Save iangow/fe69aad5c9cf2bd04ca4bafad96812e7 to your computer and use it in GitHub Desktop.
Save iangow/fe69aad5c9cf2bd04ca4bafad96812e7 to your computer and use it in GitHub Desktop.
Destinations
library(tidyverse)
library(DBI)
library(googlesheets4)

options(gargle_oauth_email = TRUE)

gs_2024 <- as_sheets_id("1Qymhw_LGN1Z00ip_qswa29yPeZzWvTymD-u-lMY8b-A")

nnhs_2024 <- read_sheet(gs_2024, na = c("", "N/A"))
#> ℹ The googlesheets4 package is using a cached token for 'iandgow@gmail.com'.
#> ✔ Reading from "NNHS2024".
#> ✔ Range 'Sheet1'.
nnhs_2024 |>
  filter(!is.na(school)) |>
  mutate(school = coalesce(school_conformed, school)) |>
  count(school, sort = TRUE) |>
  filter(n >= 4) |>
  mutate(school = fct_inorder(school)) |>
  ggplot(aes(x = school, y = n, fill = school)) +
  geom_col() +
  theme(axis.text.x = element_text(angle = 90)) +
  guides(fill = "none", color = "none")

Created on 2024-07-03 with reprex v2.1.0

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