Skip to contents

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'.

Usage

expand_input_tibble(x, type, source = FALSE)

Arguments

x

List of tibble(s). For type "preceptor", a list of length 1. For type "population", a list of length 2.

type

Character string. Either "preceptor" or "population".

source

Logical, whether the population table includes a 'Source' column. Default FALSE.

Value

A single tibble with added missing rows and 'More' column, suitable for piping to gt.

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 ...    ...   ...   ...