Row-bind an identical data frame for computing grouped totals
Source:R/totals_bind.R
totals_bind.Rd
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.
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
.
See also
Other Support:
any_idate()
,
camel_clean()
,
check_inputs()
,
cut_hour()
,
extract_date_range()
,
extract_hr()
,
heat_colours()
,
is_date_format()
,
maxmin()
,
pairwise_count()
,
read_preamble()
,
rgb2hex()
,
totals_col()
,
tstamp()
,
us_to_space()
,
wrap()
Examples
pq_data %>%
totals_bind(target_col = "LevelDesignation", target_value = "Total") %>%
create_bar(hrvar = "LevelDesignation", metric = "Email_hours", return = "table")
#> # A tibble: 6 × 3
#> group Email_hours n
#> <chr> <dbl> <int>
#> 1 Director 2.50 6
#> 2 Junior IC 0.991 10
#> 3 Manager 1.53 11
#> 4 Senior IC 1.11 20
#> 5 Support 1.08 53
#> 6 Total 1.21 100