Skip to content

Commit

Permalink
Update table1_table_collation.R
Browse files Browse the repository at this point in the history
  • Loading branch information
emprestige committed Sep 27, 2024
1 parent be54a58 commit 48b3077
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions analysis/collation_code/table1_table_collation.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,33 @@ fs::dir_create(here("output", "collated", "descriptive"))
# import table 1 by cohort
collated_table1 = rbind(
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2016_2017.csv"))) %>% mutate(subset = "2016_17"),
"_2016_2017.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2016_17") ,
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2017_2018.csv"))) %>% mutate(subset = "2017_18"),
"_2017_2018.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2017_18"),
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2018_2019.csv"))) %>% mutate(subset = "2018_19"),
"_2018_2019.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2018_19"),
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2019_2020.csv"))) %>% mutate(subset = "2019_20"),
"_2019_2020.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2019_20"),
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2020_2021.csv"))) %>% mutate(subset = "2020_21"),
"_2020_2021.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2020_21"),
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2021_2022.csv"))) %>% mutate(subset = "2021_22"),
"_2021_2022.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2021_22"),
read_csv(here::here("output", "table1", paste0("table1_", cohort,
"_2022_2023.csv"))) %>% mutate(subset = "2022_23")
"_2022_2023.csv"))) %>% rename(N = 2) %>%
mutate(N = ifelse(row_number() == 1, .[2, 2], N)) %>%
slice(-2) %>% mutate(subset = "2022_23")
)

#save as csv
Expand Down

0 comments on commit 48b3077

Please sign in to comment.