Initial commit: illustrative R data pipeline

This commit is contained in:
2026-03-09 14:20:10 -04:00
commit 83e50d2c36
12 changed files with 277 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
# 03_convert_units.R
# Reads wide-format population CSV, pivots to long, converts thousands to
# full unit count.
source("scripts/00_paths.R")
library(readr)
library(tidyr)
library(dplyr)
df <- read_csv(population_raw, show_col_types = FALSE)
df_long <- df |>
pivot_longer(
cols = jan:jun,
names_to = "month",
values_to = "value"
) |>
mutate(
value = value * 1000,
unit = "persons"
)
write_csv(df_long, population_full)
cat("04_convert_units.R: thousands -> persons, wrote df_population_full.csv\n")