Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jonspring's full-sized avatar

Jon Spring jonspring

View GitHub Profile
library(showtext)
font_add_google("Special Elite", "elite")
showtext_auto()
library(magick)
library(tidyverse)
# first part is common punctuation
chars = c(strsplit(intToUtf8(c(33:47, 58:64, 91:96)), "")[[1]],
0:9, letters, LETTERS)
tibble::tribble(
~soo, ~station_name, ~station_code, ~Location, ~County,
"ANTC", "Antioch", "AN", "Antioch", "Contra Costa",
"ASHB", "Ashby", "AS", "Berkeley", "Alameda",
"DBRK", "Berkeley", "BK", "Berkeley", "Alameda",
"NBRK", "North Berkeley", "NB", "Berkeley", "Alameda",
"CAST", "Castro Valley", "CV", "Castro Valley", "Alameda",
"COLM", "Colma", "CM", "Colma", "San Mateo",
"CONC", "Concord", "CN", "Concord", "Contra Costa",
"NCON", "North Concord / Martinez", "NC", "Concord", "Contra Costa",
@jonspring
jonspring / gist:99ace164ac40bb523675c55846b0d43c
Last active July 29, 2023 18:28
XKCD: Bad Map Projection: ABS(Longitude)
# recreation of https://xkcd.com/2807/
library(ggplot2)
library(sf)
library("rnaturalearth")
library("rnaturalearthdata")
# library(lwgeom)
world <- ne_countries(scale = "small", returnclass = "sf") |>
library(tidyverse)
library(lubridate)
# library(fitzRoy)
ranks <- tibble::tribble(
~RK, ~Team, ~PTS, ~chg,
1L, "USA", 2090.03, -1.35,
2L, "GER", 2061.56, -6.56,
library(tidyverse)
library(zipcodeR)
tuesdata <- tidytuesdayR::tt_load('2022-11-08')
state_stations <- tuesdata$state_stations
station_info <- tuesdata$station_info
zipcodeR::zip_code_db -> zips
state_stations %>%
separate(frequency, c("freq", "band"), sep = " ", convert = TRUE, remove = FALSE) %>%
library(tidyverse)
library(readxl)
library(lubridate)
library(ggdist)
historicalweeklydata <-
bind_rows(
read_excel("~/Downloads/historicalweeklydata.xls",
sheet = "Full History", range = "a7:B4000"),
# inspired by https://twitter.com/nytimes/status/1569377877774188551
# https://www.nytimes.com/2022/09/11/nyregion/hasidic-schools-nyc-officials.html
library(tidyverse);
library(particles); library(tidygraph); library(ggraph)
tibble(group = rep(c(1, 1.3), each = 300),
value = rbeta(600, 2-group, group^3),
radius = 0.01) -> a
library(tidyverse)
permits <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2022/2022-07-05/sf_permits.csv')
permits2 <- permits %>%
mutate(lon = stringr::word(location, 2) %>% parse_number,
lat = stringr::word(location, 3) %>% parse_number) %>%
mutate(use = fct_lump(proposed_use, 7) %>% fct_explicit_na())
library(ggmap)
sf_basemap = get_map(location = c(lon = -122.45, lat = 37.75),
library(httr); library(jsonlite)
library(tidyverse); library(lubridate)
library(gganimate); library(ggtext)
sf_hosp <- GET("https://data.sfgov.org/resource/nxjg-bhem.json?$limit=999999")
sf_hosp$content %>%
rawToChar %>%
fromJSON %>%
mutate(patientcount = as.numeric(patientcount),
---
title: "Test"
output: html_document
---
```{r setup, include=FALSE}
plot(mtcars$mpg)
```