Row-bind an identical data frame and impute a specific column with the target_value, which defaults as "Total". The purpose of this is to enable to creation of summary tables with a calculated "Total" row. See example below on usage.

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

Arguments

data

data frame

target_col

Character value of the column in which to impute "Total". This is usually the intended grouping column.

target_value

Character value to impute in the new data frame to row-bind. Defaults to "Total".

Value

data frame with twice the number of rows of the input data frame, where half of those rows will have the target_col column imputed with the value from target_value.

Examples

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