kassambara / rstatix

Pipe-friendly Framework for Basic Statistical Tests in R
https://rpkgs.datanovia.com/rstatix/
440 stars 50 forks source link

P value significant digits #108

Open LeiHanAVLH opened 3 years ago

LeiHanAVLH commented 3 years ago

i found a point which actually is not a issue. i found that when i use "t_test" function to calculate p Value, it always give only 3 significant digits . in some case, more digits would help. could this be optimized? Thanks!

benediktclaus commented 2 years ago

Hi @LeiHanAVLH

Can you post a reprex (reproducible example)? Meanwhile, you can try to increase the number of significant digits manually with options(pillar.sigfig = x) as shown below.

The issue might also be the p-values themselves if they don't contain any further digits (see below as well).

library(tidyverse)
library(rstatix)

example_test <- PlantGrowth %>% 
  t_test(weight ~ group)

# The output contains 3 significant digits in all columns
example_test
#> # A tibble: 3 x 10
#>   .y.    group1 group2    n1    n2 statistic    df     p p.adj p.adj.signif
#> * <chr>  <chr>  <chr>  <int> <int>     <dbl> <dbl> <dbl> <dbl> <chr>       
#> 1 weight ctrl   trt1      10    10      1.19  16.5 0.25  0.25  ns          
#> 2 weight ctrl   trt2      10    10     -2.13  16.8 0.048 0.096 ns          
#> 3 weight trt1   trt2      10    10     -3.01  14.1 0.009 0.028 *

# This behaviour can be changed like so
options(pillar.sigfig = 4)
example_test
#> # A tibble: 3 x 10
#>   .y.    group1 group2    n1    n2 statistic    df     p p.adj p.adj.signif
#> * <chr>  <chr>  <chr>  <int> <int>     <dbl> <dbl> <dbl> <dbl> <chr>       
#> 1 weight ctrl   trt1      10    10     1.191 16.52 0.25  0.25  ns          
#> 2 weight ctrl   trt2      10    10    -2.134 16.79 0.048 0.096 ns          
#> 3 weight trt1   trt2      10    10    -3.010 14.10 0.009 0.028 *

# Notice that the p-column seems not to bee affected by this option but this is
# the result of the p-values themselves. They don't have any further digits.
example_test %>% 
  pull(p)
#> [1] 0.250 0.048 0.009

Created on 2021-10-06 by the reprex package (v2.0.1)