Creates a t-test table for multiple dependent variables

nice_t_test_table(
  dv,
  iv,
  data,
  method = "cohen",
  conditions = NULL,
  labels = NULL,
  labels_conditions = NULL,
  concise = TRUE,
  nice_p = TRUE,
  digits = 1,
  var_equal = FALSE,
  label_attr = TRUE,
  manova = TRUE,
  caption = NULL,
  alternative = "two.sided",
  file = NULL,
  ...
)

Arguments

dv

A data frame with the dependent variables or a character vector with variable names when data is defined.

iv

A data frame or vector with the independent variable or a character if data is defined.

data

A data frame.

method

Either "cohen", "glass", or "hedges".

conditions

A character vector of length two with the names of the two conditions. Defaults to the first two levels of the independent variable 'iv' if applicable.

labels

A character vector of length two with labels for the dependent variables.

labels_conditions

Vector of length 2 which resets condition labels.

concise

A more concise table with mean and SD in one column.

nice_p

If TRUE, p values are printed in a nice format.

digits

Number of digits for rounding mean and SD values

var_equal

If FALSE, a t-test for unequal variances is calculated.

label_attr

If TRUE, variable labels are used if available.

manova

If TRUE, a MANOVA is calculated and its results are added to the note.

caption

Table caption is type = "html"

alternative

A character string specifying the alternative hypothesis. Must be one of "two.sided" (default), "greater" or "less".

file

Character string with filename. If set, an additional file is exported (html format is possible). If set TRUE, a filename is automatically created based on the title.

...

Additional arguments passed to nice_table().

Value

A data.frame or an html table

Examples

nice_t_test_table(
  data = mtcars, 
  iv = "am", 
  dv = c("mpg", "cyl", "disp", "hp", "drat", "wt", "qsec", "vs", "gear", "carb")
)
Table
T-test table comparing conditions 0 vs. 1 in variable am
Scale
N
M (SD)
d t df p
0 1 0 1
mpg 19 13 17.1 (3.8) 24.4 (6.2) 1.5 3.8 18.3 <.01
cyl 19 13 6.9 (1.5) 5.1 (1.6) -1.2 -3.4 25.9 <.01
disp 19 13 290.4 (110.2) 143.5 (87.2) -1.4 -4.2 29.3 <.001
hp 19 13 160.3 (53.9) 126.8 (84.1) -0.5 -1.3 18.7 .22
drat 19 13 3.3 (0.4) 4 (0.4) 2.0 5.6 27.2 <.001
wt 19 13 3.8 (0.8) 2.4 (0.6) -1.9 -5.5 29.2 <.001
qsec 19 13 18.2 (1.8) 17.4 (1.8) -0.5 -1.3 25.5 .21
vs 19 13 0.4 (0.5) 0.5 (0.5) 0.3 0.9 25.1 .36
gear 19 13 3.2 (0.4) 4.4 (0.5) 2.6 6.9 22.6 <.001
carb 19 13 2.7 (1.1) 2.9 (2.2) 0.1 0.3 16.6 .78
Note. Method for estimating d: cohen; Manova: Pillai = 0.80; F(10, 21) = 8.36; p = 0.000.
df <- data.frame( a = c(rnorm(85, 50, 10), rnorm(200, 70, 20)), b = c(rnorm(85, 50, 10), rnorm(200, 55, 20)), iv = factor(c(rep("Regular", 85), rep("Special", 100), rep("Restricted", 100))) ) nice_t_test_table( c("a", "b"), "iv", data = df, conditions = c("Restricted","Special"), labels = c("Motivation", "Achievement") )
Table
T-test table comparing conditions Restricted vs. Special in variable iv
Scale
N
M (SD)
d t df p
Restricted Special Restricted Special
Motivation 100 100 70.3 (21.3) 70.7 (18.4) 0.0 0.1 193.9 .88
Achievement 100 100 51.9 (17.1) 54.4 (22) 0.1 0.9 186.5 .38
Note. Method for estimating d: cohen; Manova: Pillai = 0.00; F(2, 197) = 0.39; p = 0.678.