Skip to content

Instantly share code, notes, and snippets.

View andrewheiss's full-sized avatar
👨‍💻
#rstats-ing all the things

Andrew Heiss andrewheiss

👨‍💻
#rstats-ing all the things
View GitHub Profile
library(tidyverse)
# Here's some state-level data
some_state_data <- tribble(
~state, ~something,
"Wyoming", 5,
"North Carolina", 9,
"Nevada", 10,
"Georgia", 3,
"Rhode Island", 1,
library(tidyverse)
library(sf)
library(rnaturalearth)
# World map
world <- ne_countries(scale = "medium") |>
filter(adm0_a3 != "ATA") |>
st_transform(crs = "+proj=merc")
# The center of the map is off the coast of Sardegna
library(tidyverse)
library(ggdiagram)

rect_width <- 1.75
rect_height <- 0.6

clrs <- MetBrewer::met.brewer("Tam")

# set_default_arrowhead(ggarrow::arrow_head_wings(offset = 30, inset = 60))
library(tidyverse)
library(ggtext)
library(patchwork)
library(scales)
top_plot <- ggplot(penguins, aes(x = body_mass)) +
geom_histogram(binwidth = 100, color = "white", boundary = 0) +
scale_x_continuous(
breaks = seq(2500, 6500, by = 1000),
limits = c(2500, 6500),
library(tidyverse)
library(ggpattern)
publication_names <- c(
"Juvenile Instructor" = "J/I",
"Der Ster" = "NE",
"Der Wegweiser" = "GM",
"Juvenile Instructor + Der Ster" = "J/I;NE",
"Juvenile Instructor + Der Wegweiser" = "J/I;GM"
)
library(tidyverse)
library(broom)
library(gapminder)
gapminder
#> # A tibble: 1,704 × 6
#>    country     continent  year lifeExp      pop gdpPercap
#>    <fct>       <fct>     <int>   <dbl>    <int>     <dbl>
#>  1 Afghanistan Asia       1952    28.8  8425333      779.
#>  2 Afghanistan Asia       1957    30.3  9240934      821.
library(tidyverse)
library(broom)
library(parameters)
library(marginaleffects)
library(palmerpenguins)

penguins <- penguins |> 
  drop_na(sex) |> 
  mutate(is_gentoo = species == "Gentoo")
matches:
# Markdown / HTML things
- trigger: ";mdl"
replace: "[$|$]({{clipb}})"
vars:
- name: "clipb"
type: "clipboard"
- trigger: ";br"
replace: "<br>"
library(tidyverse)
library(gutenbergr)
constitution_raw <- gutenberg_download(5)
constitution <- constitution_raw |>
slice(36:546) |>
filter(text != "") |>
mutate(text_lc = str_to_lower(text)) |>
mutate(is_article = str_starts(text_lc, "article")) |>