atorus-research / Tplyr

Home Page:https://atorus-research.github.io/Tplyr/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`tplyr.IBMRounding = TRUE` is not working sometime

yangwenghou123 opened this issue · comments

Description

The Mean value returned from Tplyr is not rounded correctly

Steps to Reproduce (Bug Report Only)

options(tplyr.IBMRounding = TRUE)

df <- data.frame(AGE = c(2.9, 1.8, 0.0, 0.4), TRT = "A")
sum( c(2.9, 1.8, 0.0, 0.4))/4

withr::with_options(
list(tplyr.IBMRounding = TRUE),
{
tplyr_table(df, TRT) %>%
add_layer(
group_desc(AGE, by = "Age (years)") %>%
set_format_strings(
"n" = f_str("xx", n),
"Mean (SD)"= f_str("a.a+1", mean)
)
) %>%
build()
})
Expected behavior: the Mean should be 1.28

Actual behavior: 1.27

Versions

R version 4.2.1 (2022-06-23)
Platform: x86_64-suse-linux-gnu (64-bit)
Running under: SUSE Linux Enterprise Server 15 SP4

Matrix products: default
BLAS: /usr/local/lib64/R/R-4.2.1/R/lib/libRblas.so
LAPACK: /usr/local/lib64/R/R-4.2.1/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_US.ISO-8859-1 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=C LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] rlang_1.1.1 GBEMisc_2.2.1 purrr_0.3.4 tidyr_1.2.0 assertthat_0.2.1 haven_2.5.1 openxlsx_4.2.5 officer_0.4.3 stringr_1.4.1
[10] kableExtra_1.3.4 data.table_1.14.2 Tplyr_1.1.0 R6_2.5.1 ggplot2_3.3.6 xfun_0.39 dplyr_1.1.2 gt_0.9.0

loaded via a namespace (and not attached):
[1] matrixStats_0.62.0 webshot_0.5.3 httr_1.4.4 tools_4.2.1 backports_1.4.1 utf8_1.2.2 colorspace_2.0-3 withr_2.5.0 tidyselect_1.2.0
[10] gridExtra_2.3 compiler_4.2.1 cli_3.6.1 rvest_1.0.3 xml2_1.3.3 sandwich_3.0-2 scales_1.2.1 survMisc_0.5.6 mvtnorm_1.1-3
[19] readr_2.1.2 systemfonts_1.0.4 digest_0.6.29 rmarkdown_2.15 svglite_2.1.0 pkgconfig_2.0.3 htmltools_0.5.5 fastmap_1.1.0 rstudioapi_0.14
[28] generics_0.1.3 zoo_1.8-10 zip_2.2.0 car_3.1-0 magrittr_2.0.3 modeltools_0.2-23 Formula_1.2-4 Matrix_1.4-1 Rcpp_1.0.9
[37] munsell_0.5.0 fansi_1.0.3 abind_1.4-5 lifecycle_1.0.3 stringi_1.7.8 multcomp_1.4-20 carData_3.0-5 MASS_7.3-57 grid_4.2.1
[46] parallel_4.2.1 forcats_0.5.2 table1_1.4.2 survminer_0.4.9 lattice_0.20-45 splines_4.2.1 hms_1.1.2 knitr_1.39 pillar_1.9.0
[55] ggpubr_0.4.0 uuid_1.1-0 ggsignif_0.6.3 codetools_0.2-18 stats4_4.2.1 glue_1.6.2 evaluate_0.16 vctrs_0.6.3 tzdb_0.3.0
[64] gtable_0.3.0 km.ci_0.5-6 coin_1.4-2 libcoin_1.0-9 xtable_1.8-4 broom_1.0.0 rstatix_0.7.0 survival_3.3-1 viridisLite_0.4.1
[73] tibble_3.2.1 KMsurv_0.1-5 TH.data_1.1-1 ellipsis_0.3.2

@yangwenghou123 you're using the CRAN version of Tplyr, correct?

Ok - there's a fix in the devel branch for this already. #126