For a given data frame, reorder a row to the first row of that data frame through matching a value of a variable. The intended usage of this function is to be used for reordering the "Total" row, and not with "flat" data. This can be used in conjunction with totals_bind(), which is used to create a "Total" row in the data.

totals_reorder(data, target_col, target_value = "Total")

Arguments

data

Summary table in the form of a data frame.

target_col

Character value of the column in which to reorder

target_value

Character value of the value in target_col to match

Value

data frame with the 'Total' row reordered to the bottom.

Examples

sq_data %>%
  totals_bind(target_col = "LevelDesignation",
              target_value = "Total") %>%
  collab_sum(hrvar = "LevelDesignation",
             return = "table") %>%
  totals_reorder(target_col = "group", target_value = "Total")
#> # A tibble: 6 × 5
#>   group     Meeting_hours Email_hours Total Employee_Count
#>   <chr>             <dbl>       <dbl> <dbl>          <int>
#> 1 Total             10.5        10.2   20.7            629
#> 2 Director           8.87        9.74  18.6             43
#> 3 Junior IC         10.6         9.97  20.6             58
#> 4 Manager           11.6        11.2   22.8            200
#> 5 Senior IC         11.0        10.4   21.4             67
#> 6 Support            9.66        9.60  19.3            257