Skip to content

Commit

Permalink
refactor(app): #60 namespace dplyr::filter
Browse files Browse the repository at this point in the history
Calling out specially, because of name conflict with base function
  • Loading branch information
AlexAxthelm committed Feb 26, 2024
1 parent d93b71c commit 93a981b
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions prepare_pacta_indices.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# necessary packages -----------------------------------------------------------
# please add all dependencies to imports.R
suppressPackageStartupMessages({
library("dplyr")
library("purrr")
library("readr")
})

# config
readRenviron(".env")
Expand Down Expand Up @@ -105,7 +100,7 @@ for (portfolio_name in portfolio_names) {

portfolio <-
ishares_indices %>%
filter(portfolio_name == .env$portfolio_name)
dplyr::filter(portfolio_name == .env$portfolio_name)

investor_name <- unique(portfolio$investor_name)

Expand Down Expand Up @@ -205,11 +200,11 @@ combined <-
))

combined %>%
filter(!grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(!grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_equity_results_portfolio.rds"))

combined %>%
filter(grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_bonds_results_portfolio.rds"))

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -238,11 +233,11 @@ combined_emissions <-
))

combined_emissions %>%
filter(!grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(!grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_equity_emissions.rds"))

combined_emissions %>%
filter(grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_bonds_emissions.rds"))

# -------------------------------------------------------------------------
Expand Down Expand Up @@ -271,9 +266,9 @@ combined_audit <-
))

combined_audit %>%
filter(!grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(!grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_equity_audit.rds"))

combined_audit %>%
filter(grepl("Global Corp Bond", portfolio_name)) %>%
dplyr::filter(grepl("Global Corp Bond", portfolio_name)) %>%
saveRDS(file.path(output_dir, "Indices_bonds_audit.rds"))

0 comments on commit 93a981b

Please sign in to comment.