Expand input tibble(s) by adding a 'More' column and missing rows, then combine if population
Source:R/p_table_helpers.R
expand_input_tibble.Rd
Processes one or two input tibbles to add missing rows (to at least 3 rows), a final "More" column with "..." in the last row, and combines them if type is 'population'.
Details
For "preceptor": adds a third row between the last 2 rows filled with "...", adds a "More" column with "..." in all positions.
For "population": expands each tibble similarly, then combines them with empty rows before, between, and after, then adds "More" column with "...".
Examples
# Preceptor example
pre_tib <- tibble::tribble(~Unit, ~Year, ~Outcome,
"A", "2020", "5",
"B", "2021", "6",
"C", "2022", "7")
expand_input_tibble(list(pre_tib), "preceptor")
#> # A tibble: 4 × 4
#> Unit Year Outcome More
#> <chr> <chr> <chr> <chr>
#> 1 A 2020 5 ...
#> 2 B 2021 6 ...
#> 3 ... ... ... ...
#> 4 C 2022 7 ...
# Population example
pop1 <- tibble::tribble(~Source, ~Unit, ~Year,
"S1", "A", "2020",
"S2", "B", "2021",
"S3", "C", "2022")
pop2 <- tibble::tribble(~Source, ~Unit, ~Year,
"S1", "D", "2023",
"S2", "E", "2024",
"S3", "F", "2025")
expand_input_tibble(list(pop1, pop2), "population", source = TRUE)
#> # A tibble: 10 × 4
#> Source Unit Year More
#> <chr> <chr> <chr> <chr>
#> 1 ... ... ... ...
#> 2 S1 A 2020 ...
#> 3 S2 B 2021 ...
#> 4 ... ... ... ...
#> 5 ... ... ... ...
#> 6 ... ... ... ...
#> 7 S1 D 2023 ...
#> 8 S2 E 2024 ...
#> 9 S3 F 2025 ...
#> 10 ... ... ... ...