Skip to contents

Create a summary table with t.test: statistic, p-value and IC(95%).

Usage

stat_two_num(df, grp_var, num_vars)

Arguments

df

A single data.frame

grp_var

A character variable from a data.frame

num_vars

One or more variables from a data.frame

Value

A gt table.

Examples


n <- 20

set.seed(123);df <-
 data.frame(
   grp_var = sample(paste("group", letters[1:2]),size = n,replace = TRUE),
   num_var1 = rnorm(n),
   num_var2 = abs(rnorm(n))
 )

stat_two_num(df,grp_var,c(num_var1,num_var2))
#> Joining with `by = join_by(name)`
#> Joining with `by = join_by(name)`
Variables group a n = 11 group b n = 9 Statistic P-value CI (95%)
num_var11 -0.04 (0.95) -0.19 (1.14) 0.297 0.7705 (-0.868; 1.151)
num_var22 0.47 (0.52) 0.69 (0.48) 48.000 0.9408 (-0.411; 0.405)
1 Mean (SD) - Student's t-test
2 Median (IQR) - Wilcoxon test