Skip to content

Instantly share code, notes, and snippets.

View Straubinger's full-sized avatar

Simon Grundt Straubinger Straubinger

View GitHub Profile
@marcosci
marcosci / street_orientation.R
Created May 10, 2023 12:36
street_orientation
# load libraries
library(tidyverse)
library(osmdata)
library(sf)
library(ggtext)
library(exactextractr)
library(fasterize)
library(ggtext)
library(tidygeocoder)
library(glue)
## Replication of https://archive.org/details/ost-geography-completegeograph00sauluoft/page/n574/mode/1up
# Inspired by @PaoloCrosetto's question and @geokaramanis's implementation
# https://twitter.com/PaoloCrosetto/status/1448594997251657731
# https://twitter.com/geokaramanis/status/1447913599712825349
library(tidyverse)
countries <- c("Belgium", "England", "Japan", "Italy", "China", "Germany", "France", "India", "Spain", "Phil. Is'ds", "Russia", "Cuba", "U. States", "Mexico", "Hawaii", "C.Colony", "Brazil", "Argentina", "Canada", "Australia")
densities <- c(563,500,284,280,270,250,186,184,89,72,54,36,20,16,16,5,4.5,3,2,1.23)
df <- tibble(country=factor(countries, levels=countries), # Trick to keep the order
@tanho63
tanho63 / scoobydoo_pivot.R
Last active September 25, 2023 19:19
pivot_longer sentinel .value - scoobydoo tidy tuesday
library(tidyverse)
scooby_data <- read.csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-07-13/scoobydoo.csv")
x <-
scooby_data %>%
select(season, title,
starts_with("caught"),
starts_with("captured"),
starts_with("unmask"),
library(tidycensus)
library(ggiraph)
library(tidyverse)
library(patchwork)
vt_income <- get_acs(
geography = "county",
variables = "B19013_001",
state = "VT",
year = 2019,
@sharlagelfand
sharlagelfand / labeller
Created March 26, 2021 16:00
Demonstrating the usage of the argument `labeller = label_wrap_gen()` in the ggplot2 function facet_wrap()
library(ggplot2)
library(tibble)
df <- tribble(
~x, ~y, ~label,
1, 2, "A super long label oh god how am I going to deal with this",
2, 1, "A shorter one"
)
# Default - text is cut off
# Colors via http://clrs.cc/
clrs <- list(
  navy = "#001F3F",
  blue = "#0074D9",
  aqua = "#7FDBFF",
  teal = "#39CCCC",
  olive = "#3D9970",
  green = "#2ECC40",
 lime = "#01FF70",
library(tidyverse)
library(sf)
# https://github.com/jvangeld/ME-GIS
coastline <- read_sf("ME-GIS-master/Coastline2.shp")
contours <- read_sf("ME-GIS-master/Contours_18.shp")
rivers <- read_sf("ME-GIS-master/Rivers.shp")
lakes <- read_sf("ME-GIS-master/Lakes.shp")
forests <- read_sf("ME-GIS-master/Forests.shp")
mountains <- read_sf("ME-GIS-master/Mountains_Anno.shp")
library(tidyverse)
library(tidytext)
library(gutenbergr)
library(cleanNLP)
little_women_raw <- gutenberg_download(514, meta_fields = "title")
little_women <- little_women_raw %>%
slice(70:n()) %>%
mutate(chapter_start = str_detect(text, "^CHAPTER"),
@kjhealy
kjhealy / apple-covid.R
Last active May 27, 2020 15:54
Get Apple's COVID data in R
## Get current Apple COVID data
## Kieran Healy / @kjhealy
## E.g. apple_covid <- get_apple_data()
## 1. Find today's URL
## Thanks to David Cabo (@dcabo) for alerting me to the existence of the json file.
get_apple_target <- function(cdn_url = "https://covid19-static.cdn-apple.com",
json_file = "covid19-mobility-data/current/v3/index.json") {
tf <- tempfile(fileext = ".json")
## Infrastructure notes ########################################################
# I am running this in docker image rocker/tidyverse:3.6.1
# Load packages
library(tidyverse)
library(EpiEstim)
## Fetch data from the covid19data API #########################################
url <- "https://api.covid19data.dk/ssi_newly_hospitalized"