Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobvjk committed Apr 3, 2024
1 parent 4f4ace5 commit 904d28f
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions prepare_abcd.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,14 @@ if (!all(cols_abcd$col_names_abcd %in% names(abcd))) {

# optional: remove inactive companies----

# remove company-sector combinations where production in t5 = 0 when
# (1) remove company-sector combinations where production in t5 = 0 when
# it was greater than 0 in t0.
# (2) remove company-sector combinations where production is 0 for the entire
# time frame from t0 to t5.
rm_inactive_companies <- function(data,
start_year,
time_frame) {
data_no_prod_t5 <- data %>%
comp_sec_no_prod_t5 <- data %>%
dplyr::filter(
year %in% c(.env$start_year, .env$start_year + .env$time_frame)
) %>%
Expand All @@ -95,15 +97,13 @@ rm_inactive_companies <- function(data,
dplyr::filter(
!!rlang::sym(paste0("prod_", start_year)) > 0,
!!rlang::sym(paste0("prod_", start_year + time_frame)) == 0
)

comp_sec_no_prod_t5 <- data_no_prod_t5 %>%
) %>%
dplyr::distinct(
.data$name_company,
.data$sector
)

data_no_prod_t0_to_t5 <- data %>%
comp_sec_no_prod_t0_to_t5 <- data %>%
dplyr::filter(
year %in% c(.env$start_year, .env$start_year + .env$time_frame)
) %>%
Expand All @@ -113,9 +113,7 @@ rm_inactive_companies <- function(data,
) %>%
dplyr::filter(
.data$sum_production == 0
)

comp_sec_no_prod_t0_to_t5 <- data_no_prod_t0_to_t5 %>%
) %>%
dplyr::distinct(
.data$name_company,
.data$sector
Expand Down

0 comments on commit 904d28f

Please sign in to comment.