Initial commit: illustrative R data pipeline
This commit is contained in:
18
scripts/07_calc.R
Normal file
18
scripts/07_calc.R
Normal file
@@ -0,0 +1,18 @@
|
||||
# 05_calc.R
|
||||
# Reads merged data and calculates income per person.
|
||||
|
||||
source("scripts/00_paths.R")
|
||||
|
||||
library(readr)
|
||||
library(dplyr)
|
||||
|
||||
df_merged <- read_csv(merged, show_col_types = FALSE)
|
||||
|
||||
df_result <- df_merged |>
|
||||
mutate(income_per_person = round(value_usd / population, 4)) |>
|
||||
select(month, value_usd, population, income_per_person)
|
||||
|
||||
write_csv(df_result, result)
|
||||
|
||||
cat("05_calc.R: calculated income per person, wrote df_result.csv\n")
|
||||
print(df_result)
|
||||
Reference in New Issue
Block a user