Uses dplyr::summarise_at() to add pounds, shillings, and pence in one or more lsd list columns in a data frame.

deb_summarise(df, ..., round = 5, na.rm = FALSE)

Arguments

df

A data frame that contains pounds, shillings, and pence variables.

...

lsd list column or columns to be summed.

round

Round pence unit to specified number of decimal places. Default is 5. Set to 0 to return pence as whole number.

na.rm

Logical. Passed on to na.rm argument in sum(). Whether missing values (NA) should be removed. Default is FALSE.

Value

Returns a data frame with one level of grouping dropped and lsd list columns.

Details

When used on a data frame without any grouping, the result will be a data frame with a single row consisting of the lsd list columns chosen to be summarised. When used in conjunction with dplyr::group_by(), deb_summarise() will return a sum of the lsd list columns for each group.

Examples

library(tibble) library(dplyr)
#> #> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’: #> #> filter, lag
#> The following objects are masked from ‘package:base’: #> #> intersect, setdiff, setequal, union
# Tibble with an lsd list column lsd_list <- deb_as_lsd(list(c(3, 10, 9), c(5, 18, 11), c(6, 11, 10), c(2, 16, 5)), bases = c(20, 12)) example <- tibble(group = c(1, 2, 1, 2), lsd = lsd_list) # Sum of the lsd list column deb_summarise(df = example, lsd)
#> # A tibble: 1 x 1 #> lsd #> <S3: lsd> #> 1 18, 17, 11
# Sum of groups of the lsd list column example %>% group_by(group) %>% deb_summarise(lsd)
#> # A tibble: 2 x 2 #> group lsd #> <dbl> <S3: lsd> #> 1 1 10, 2, 7 #> 2 2 8, 15, 4