ddsjoberg / gtsummary

Presentation-Ready Data Summary and Analytic Result Tables
http://www.danieldsjoberg.com/gtsummary
Other
1.04k stars 116 forks source link

Unexpected p-values in add_p.tbl_summary (continuous variable) #525

Closed matthieu-faron closed 4 years ago

matthieu-faron commented 4 years ago

Hi, thanks again for this great package.

I encounter a unexpected behaviour with continuous variable
Both this approaches lead to significant differences in age

trial[c("age", "grade", "response", "trt")] %>%
  tbl_summary(by = trt) %>%
  add_p()

trial[c("age", "grade", "response", "trt")] %>%
tbl_summary(by = trt) %>%
add_p(list(all_continuous() ~ "wilcox.test"))

While, doing the test itself return not significant p-values

wilcox.test(age ~ trt, data = trial)
kruskal.test(age ~ trt, data = trial)

And Student t-test also lead to non significant p-values

trial[c("age", "grade", "response", "trt")] %>%
  tbl_summary(by = trt) %>%
  add_p(list(all_continuous() ~ "t.test"))

The vignette on the site, also shows no significant differences in age for this dataset suggestinf that the problem may be due to an update in the package code ?

My sessionInfo()


R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                   LC_TIME=French_France.1252    

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

other attached packages:
 [1] labelled_2.4.0  gtsummary_1.3.1 knitr_1.28      survminer_0.4.7 ggpubr_0.3.0    survival_3.1-12 forcats_0.5.0   stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4    
[11] readr_1.3.1     tidyr_1.1.0     tibble_3.0.1    ggplot2_3.3.1   tidyverse_1.3.0

loaded via a namespace (and not attached):
 [1] httr_1.4.1         sass_0.2.0         viridisLite_0.3.0  jsonlite_1.6.1     splines_4.0.0      carData_3.0-4      modelr_0.1.8       assertthat_0.2.1   huxtable_4.7.1    
[10] blob_1.2.1         cellranger_1.1.0   yaml_2.2.1         pillar_1.4.4       backports_1.1.7    lattice_0.20-41    glue_1.4.1         digest_0.6.25      RColorBrewer_1.1-2
[19] ggsignif_0.6.0     checkmate_2.0.0    rvest_0.3.5        colorspace_1.4-1   cowplot_1.0.0      htmltools_0.4.0    Matrix_1.2-18      pkgconfig_2.0.3    broom_0.5.6       
[28] haven_2.3.1        xtable_1.8-4       scales_1.1.1       km.ci_0.5-2        openxlsx_4.1.5     rio_0.5.16         KMsurv_0.1-5       farver_2.0.3       generics_0.0.2    
[37] car_3.0-8          ellipsis_0.3.1     withr_2.2.0        cli_2.0.2          magrittr_1.5       crayon_1.3.4       readxl_1.3.1       fs_1.4.1           fansi_0.4.1       
[46] nlme_3.1-148       rstatix_0.5.0      xml2_1.3.2         foreign_0.8-80     tools_4.0.0        data.table_1.12.8  hms_0.5.3          lifecycle_0.2.0    munsell_0.5.0     
[55] reprex_0.3.0       zip_2.0.4          compiler_4.0.0     rlang_0.4.6        grid_4.0.0         gt_0.2.1           rstudioapi_0.11    labeling_0.3       gtable_0.3.0      
[64] abind_1.4-5        DBI_1.1.0          curl_4.3           R6_2.4.1           gridExtra_2.3      zoo_1.8-8          lubridate_1.7.8    survMisc_0.5.5     commonmark_1.7    
[73] stringi_1.4.6      Rcpp_1.0.4.6       vctrs_0.3.1        dbplyr_1.4.4       tidyselect_1.1.0   xfun_0.14         ```
ddsjoberg commented 4 years ago

@matthieu-faron thank you so much for this report. this error was included in last week's release. this has been fixed, and an updated version of the package has been submitted to CRAN