This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| dig_sub = function(x) { | |
| x = str_pad(x, 4, side = "left", pad = 0) | |
| my_list = str_split(x, pattern = "", simplify = TRUE) | |
| small = my_list[order(my_list)] |> paste0(collapse = "") |> as.numeric() | |
| large = my_list[rev(order(my_list))] |> paste0(collapse = "") |> as.numeric() | |
| list(x, large, small, large - small) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| files = c( | |
| fs::dir_ls("~/Downloads/Shelter1_Tension_files"), | |
| fs::dir_ls("~/Downloads/Shelter_2_Tension_files")) | |
| doggies <- data.frame(file = files) |> | |
| mutate(data = map(files, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # recreation of https://xkcd.com/2807/ | |
| library(ggplot2) | |
| library(sf) | |
| library("rnaturalearth") | |
| library("rnaturalearthdata") | |
| # library(lwgeom) | |
| world <- ne_countries(scale = "small", returnclass = "sf") |> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(tidyverse) | |
| library(readxl) | |
| library(lubridate) | |
| library(ggdist) | |
| historicalweeklydata <- | |
| bind_rows( | |
| read_excel("~/Downloads/historicalweeklydata.xls", | |
| sheet = "Full History", range = "a7:B4000"), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), |
NewerOlder