From 8a30fe338e2ed39f996f5020c02324db2b3630aa Mon Sep 17 00:00:00 2001 From: Rob Wiederstein Date: Mon, 9 Mar 2026 14:34:43 -0400 Subject: [PATCH] Centralize library loading in 00_paths.R to suppress dplyr startup messages --- .gitignore | 4 ++++ data/formatted/df_formatted.csv | 7 +++++++ data/interim/df_income_usd.csv | 7 +++++++ data/interim/df_income_usd_wide.csv | 2 ++ data/interim/df_merged.csv | 7 +++++++ data/interim/df_population_full.csv | 7 +++++++ data/processed/df_result.csv | 7 +++++++ data/raw/df_income.csv | 2 ++ data/raw/df_population.csv | 2 ++ powershell_example.Rproj | 14 ++++++++++++++ scripts/00_paths.R | 10 +++++++++- scripts/01_create_data.R | 2 -- scripts/02_validate.R | 1 - scripts/03_convert_currency.R | 2 -- scripts/04_pivot_income.R | 2 -- scripts/05_convert_units.R | 3 --- scripts/06_merge.R | 2 -- scripts/07_calc.R | 2 -- scripts/08_format.R | 2 -- 19 files changed, 68 insertions(+), 17 deletions(-) create mode 100644 .gitignore create mode 100644 data/formatted/df_formatted.csv create mode 100644 data/interim/df_income_usd.csv create mode 100644 data/interim/df_income_usd_wide.csv create mode 100644 data/interim/df_merged.csv create mode 100644 data/interim/df_population_full.csv create mode 100644 data/processed/df_result.csv create mode 100644 data/raw/df_income.csv create mode 100644 data/raw/df_population.csv create mode 100644 powershell_example.Rproj diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5b6a065 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata diff --git a/data/formatted/df_formatted.csv b/data/formatted/df_formatted.csv new file mode 100644 index 0000000..0eb3ba5 --- /dev/null +++ b/data/formatted/df_formatted.csv @@ -0,0 +1,7 @@ +month,value_usd,population,income_per_person +jan,45360000,22600000,2.01 +feb,42660000,22600000,1.89 +mar,47736000,22650000,2.11 +apr,45144000,22650000,1.99 +may,46548000,22700000,2.05 +jun,43848000,22700000,1.93 diff --git a/data/interim/df_income_usd.csv b/data/interim/df_income_usd.csv new file mode 100644 index 0000000..e56cfb9 --- /dev/null +++ b/data/interim/df_income_usd.csv @@ -0,0 +1,7 @@ +id,category,denomination,month,value_usd +1,income,usd,jan,45360000 +1,income,usd,feb,42660000 +1,income,usd,mar,47736000 +1,income,usd,apr,45144000 +1,income,usd,may,46548000 +1,income,usd,jun,43848000 diff --git a/data/interim/df_income_usd_wide.csv b/data/interim/df_income_usd_wide.csv new file mode 100644 index 0000000..79acb2f --- /dev/null +++ b/data/interim/df_income_usd_wide.csv @@ -0,0 +1,2 @@ +id,category,denomination,jan,feb,mar,apr,may,jun +1,income,usd,45360000,42660000,47736000,45144000,46548000,43848000 diff --git a/data/interim/df_merged.csv b/data/interim/df_merged.csv new file mode 100644 index 0000000..a1454f5 --- /dev/null +++ b/data/interim/df_merged.csv @@ -0,0 +1,7 @@ +id,category,denomination,month,value_usd,population +1,income,usd,jan,45360000,22600000 +1,income,usd,feb,42660000,22600000 +1,income,usd,mar,47736000,22650000 +1,income,usd,apr,45144000,22650000 +1,income,usd,may,46548000,22700000 +1,income,usd,jun,43848000,22700000 diff --git a/data/interim/df_population_full.csv b/data/interim/df_population_full.csv new file mode 100644 index 0000000..f68b0fb --- /dev/null +++ b/data/interim/df_population_full.csv @@ -0,0 +1,7 @@ +state,category,unit,month,value +FL,population,persons,jan,22600000 +FL,population,persons,feb,22600000 +FL,population,persons,mar,22650000 +FL,population,persons,apr,22650000 +FL,population,persons,may,22700000 +FL,population,persons,jun,22700000 diff --git a/data/processed/df_result.csv b/data/processed/df_result.csv new file mode 100644 index 0000000..30b70cf --- /dev/null +++ b/data/processed/df_result.csv @@ -0,0 +1,7 @@ +month,value_usd,population,income_per_person +jan,45360000,22600000,2.0071 +feb,42660000,22600000,1.8876 +mar,47736000,22650000,2.1075 +apr,45144000,22650000,1.9931 +may,46548000,22700000,2.0506 +jun,43848000,22700000,1.9316 diff --git a/data/raw/df_income.csv b/data/raw/df_income.csv new file mode 100644 index 0000000..174b176 --- /dev/null +++ b/data/raw/df_income.csv @@ -0,0 +1,2 @@ +id,category,denomination,jan,feb,mar,apr,may,jun +1,income,euro,42000000,39500000,44200000,41800000,43100000,40600000 diff --git a/data/raw/df_population.csv b/data/raw/df_population.csv new file mode 100644 index 0000000..1e1d2ea --- /dev/null +++ b/data/raw/df_population.csv @@ -0,0 +1,2 @@ +state,category,unit,jan,feb,mar,apr,may,jun +FL,population,thousands,22600,22600,22650,22650,22700,22700 diff --git a/powershell_example.Rproj b/powershell_example.Rproj new file mode 100644 index 0000000..e439286 --- /dev/null +++ b/powershell_example.Rproj @@ -0,0 +1,14 @@ +Version: 1.0 +ProjectId: eefd8667-a6d0-4498-9b76-03f1e7bd10c9 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/scripts/00_paths.R b/scripts/00_paths.R index 3d460c1..f45e02f 100644 --- a/scripts/00_paths.R +++ b/scripts/00_paths.R @@ -2,7 +2,15 @@ # Central path constants and config. Source this at the top of every script. # All paths are relative to the project root. -dotenv::load_dot_env(".env") +suppressPackageStartupMessages({ + library(dotenv) + library(tibble) + library(readr) + library(tidyr) + library(dplyr) +}) + +load_dot_env(".env") euro_to_dollar_conversion_ratio <- as.numeric(Sys.getenv("euro_to_dollar_conversion_ratio")) input_cols <- as.integer(Sys.getenv("input_cols")) diff --git a/scripts/01_create_data.R b/scripts/01_create_data.R index 26260e5..582a42a 100644 --- a/scripts/01_create_data.R +++ b/scripts/01_create_data.R @@ -5,8 +5,6 @@ source("scripts/00_paths.R") -library(tibble) -library(readr) df_income <- tribble( ~id, ~category, ~denomination, ~jan, ~feb, ~mar, ~apr, ~may, ~jun, diff --git a/scripts/02_validate.R b/scripts/02_validate.R index 2cdc651..06358e0 100644 --- a/scripts/02_validate.R +++ b/scripts/02_validate.R @@ -3,7 +3,6 @@ source("scripts/00_paths.R") -library(readr) df_income <- read_csv(income_raw, show_col_types = FALSE) df_population <- read_csv(population_raw, show_col_types = FALSE) diff --git a/scripts/03_convert_currency.R b/scripts/03_convert_currency.R index 24af832..3a13a27 100644 --- a/scripts/03_convert_currency.R +++ b/scripts/03_convert_currency.R @@ -4,8 +4,6 @@ source("scripts/00_paths.R") -library(readr) -library(dplyr) df <- read_csv(income_raw, show_col_types = FALSE) diff --git a/scripts/04_pivot_income.R b/scripts/04_pivot_income.R index b59b700..6e4d2b1 100644 --- a/scripts/04_pivot_income.R +++ b/scripts/04_pivot_income.R @@ -3,8 +3,6 @@ source("scripts/00_paths.R") -library(readr) -library(tidyr) df <- read_csv(income_usd_wide, show_col_types = FALSE) diff --git a/scripts/05_convert_units.R b/scripts/05_convert_units.R index c77dbe0..25d9b51 100644 --- a/scripts/05_convert_units.R +++ b/scripts/05_convert_units.R @@ -4,9 +4,6 @@ source("scripts/00_paths.R") -library(readr) -library(tidyr) -library(dplyr) df <- read_csv(population_raw, show_col_types = FALSE) diff --git a/scripts/06_merge.R b/scripts/06_merge.R index e7ca602..c1ce2bb 100644 --- a/scripts/06_merge.R +++ b/scripts/06_merge.R @@ -3,8 +3,6 @@ source("scripts/00_paths.R") -library(readr) -library(dplyr) df_income <- read_csv(income_usd, show_col_types = FALSE) df_pop <- read_csv(population_full, show_col_types = FALSE) |> diff --git a/scripts/07_calc.R b/scripts/07_calc.R index f615f43..62cfe35 100644 --- a/scripts/07_calc.R +++ b/scripts/07_calc.R @@ -3,8 +3,6 @@ source("scripts/00_paths.R") -library(readr) -library(dplyr) df_merged <- read_csv(merged, show_col_types = FALSE) diff --git a/scripts/08_format.R b/scripts/08_format.R index f8c962c..bd28e85 100644 --- a/scripts/08_format.R +++ b/scripts/08_format.R @@ -3,8 +3,6 @@ source("scripts/00_paths.R") -library(readr) -library(dplyr) df <- read_csv(result, show_col_types = FALSE)