-
Notifications
You must be signed in to change notification settings - Fork 218
Closed
Milestone
Description
Prework
- Read and agree to the code of conduct and contributing guidelines.
- If there is already a relevant issue, whether open or closed, comment on the existing thread instead of posting a new issue.
Description
Sum of durations is incorrect.
Update: There is a smaller reproducible example in the next comment.
Update 2: PR #1375 contains a unit test for the described problem.
Update 3: PR #1375 now also contains a fix for the problem. However, the pre-existing unit tests are incorrect and still need to be updated.
Reproducible example
library(gt)
data.frame(duration = c(90L, 2160L)) %>%
gt() %>%
fmt_duration(
columns = "duration",
input_units = "minutes",
output_units = c("hours", "minutes")
) %>%
grand_summary_rows(
columns = "duration",
fns = list(Total ~ sum(.)),
fmt = list(~fmt_duration(
.,
columns = "duration",
input_units = "minutes",
output_units = c("hours", "minutes")
))
)This results in the table:
| duration | |
|---|---|
| 1h 30m | |
| 36h | |
| Total | 37h 29m |
Expected result
I would have expected the total to be 37h 30m:
| duration | |
|---|---|
| 1h 30m | |
| 36h | |
| Total | 37h 30m |
Session info
R version 4.2.3 (2023-03-15)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora Linux 37 (Workstation Edition)
Matrix products: default
BLAS/LAPACK: /usr/lib64/libflexiblas.so.3.3
locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] gt_0.9.0
loaded via a namespace (and not attached):
[1] fansi_1.0.4 withr_2.5.0 digest_0.6.31 utf8_1.2.3
[5] dplyr_1.1.2 R6_2.5.1 lifecycle_1.0.3 jsonlite_1.8.7
[9] magrittr_2.0.3 pillar_1.9.0 rlang_1.1.1 cli_3.6.1
[13] xml2_1.3.4 vctrs_0.6.3 generics_0.1.3 tools_4.2.3
[17] glue_1.6.2 fastmap_1.1.1 compiler_4.2.3 pkgconfig_2.0.3
[21] htmltools_0.5.5 tidyselect_1.2.0 sass_0.4.6 tibble_3.2.1
Metadata
Metadata
Assignees
Type
Projects
Status
Done