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)
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")) |>
library(tidyverse)
library(readxl)
library(tinytable)
# Load data downloaded from https://www.systemicpeace.org/inscrdata.html
polity <- read_excel("~/Downloads/p5v2018.xls") |>
mutate(polity_change = polity2 - lag(polity2), .by = scode) |>
filter(year > 1800)
# Find the biggest drops in polity scores since 1985
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Toggle Litra
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 💡
library(tidyverse)

# Colors too dark
mtcars |> 
  mutate(carb = factor(carb)) |> 
  ggplot(aes(carb, fill = carb)) +
  geom_bar() +
  scale_fill_viridis_d(
 option = "magma", begin = 0.1, end = 0.8
library(tidyverse)
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
library(rnaturalearth)

# All countries
countries <- ne_countries(scale = 50) |>
  filter(iso_a3 != "ATA")
library(tidyverse)

# Example data
plot_data <- mpg |> 
  mutate(cyl = factor(cyl)) |> 
  group_by(cyl) |> 
  summarize(n = n())

# ew that yellow is gross
---
title: Panel tabset from list of plots
---
```{r}
#| warning: false
#| message: false
library(tidyverse)
library(glue)