Teaching
- https://r-primers.andrewheiss.com/
- https://evalsp25.classes.andrewheiss.com/
- https://datavizsp25.classes.andrewheiss.com/
Blogging
| 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.8library(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) |
library(tidyverse)
mean_sales <- c(dairy = 5364.5846, meat = 5059.6955, fish = 764.4324, deli = 1744.4206, cheese = 364.5226)
sd_sales <- c(dairy = 1192.3751, meat = 1560.7741, fish = 333.7008, deli = 509.8426, cheese = 127.2061)
# This is from the lesson---this is how you iterate over two things
map2(mean_sales, sd_sales, \(.x, .y) rnorm(30, .x, .y))
#> $dairy
#> [1] 5260.738 5948.625 4823.229 5332.571 5087.384 3951.635 3381.243 4245.053