Skip to contents

Pivots the input dataframe so the values of the column group_name are transformed into columns that contain values from the group_level column.

Usage

splitGroup(result, keep = FALSE, fill = "overall")

Arguments

result

A dataframe with at least the columns group_name and group_level.

keep

Whether to keep the original group_name and group_level columns.

fill

Optionally, a character that specifies what value should be filled in with when missing.

Value

A dataframe.

Examples

mockSummarisedResult() |>
  splitGroup()
#> # A tibble: 126 × 12
#>    result_id cdm_name cohort_name strata_name       strata_level   variable_name
#>        <int> <chr>    <chr>       <chr>             <chr>          <chr>        
#>  1         1 mock     cohort1     overall           overall        number subje…
#>  2         1 mock     cohort1     age_group &&& sex <40 &&& Male   number subje…
#>  3         1 mock     cohort1     age_group &&& sex >=40 &&& Male  number subje…
#>  4         1 mock     cohort1     age_group &&& sex <40 &&& Female number subje…
#>  5         1 mock     cohort1     age_group &&& sex >=40 &&& Fema… number subje…
#>  6         1 mock     cohort1     sex               Male           number subje…
#>  7         1 mock     cohort1     sex               Female         number subje…
#>  8         1 mock     cohort1     age_group         <40            number subje…
#>  9         1 mock     cohort1     age_group         >=40           number subje…
#> 10         1 mock     cohort2     overall           overall        number subje…
#> # ℹ 116 more rows
#> # ℹ 6 more variables: variable_level <chr>, estimate_name <chr>,
#> #   estimate_type <chr>, estimate_value <chr>, additional_name <chr>,
#> #   additional_level <chr>