Skip to contents

statistical test which returns a extensible tibble

Usage

stat_test(
  df,
  y,
  x,
  .by = NULL,
  trans = "identity",
  paired = FALSE,
  paired_by = NULL,
  alternative = "two.sided",
  exclude_func = NULL,
  method = "wilcoxon",
  ns_symbol = "NS",
  digits = 2
)

Arguments

df

tibble

y

value

x

sample test group

.by

super-group

trans

scale transformation

paired

paired samples or not

paired_by

a column for pair

alternative

one of "two.sided" (default), "greater" or "less"

exclude_func

a function has two arguments and return bool value, used if paired=TRUE and will keep the comparation pairs which return TRUE by this function.

method

test method, 'wilcoxon' as default, one of t|wilcoxon

ns_symbol

symbol of nonsignificant, 'NS' as default

digits

significant figure digits of p value If the data pair of a single test returns TRUE, then exclude this pair

Value

test result tibble

Examples

stat_test(mini_diamond, y = price, x = cut, .by = clarity)
#> # A tibble: 24 × 9
#>    y     clarity group1 group2    n1    n2 p      plim psymbol
#>    <chr> <chr>   <chr>  <chr>  <int> <int> <chr> <dbl> <chr>  
#>  1 price I1      Fair   Good       5     5 0.31   1.01 NS     
#>  2 price I1      Fair   Ideal      5     4 0.90   1.01 NS     
#>  3 price I1      Good   Ideal      5     4 0.19   1.01 NS     
#>  4 price IF      Fair   Good       4     5 0.063  1.01 NS     
#>  5 price IF      Fair   Ideal      4     4 0.059  1.01 NS     
#>  6 price IF      Good   Ideal      5     4 1.0    1.01 NS     
#>  7 price SI1     Fair   Good       5     4 1.0    1.01 NS     
#>  8 price SI1     Fair   Ideal      5     5 1.0    1.01 NS     
#>  9 price SI1     Good   Ideal      4     5 0.41   1.01 NS     
#> 10 price SI2     Fair   Good       4     4 0.057  1.01 NS     
#> # ℹ 14 more rows