print_ttest | R Documentation |
Print the results of a t-test
print_ttest(
t_object,
d_object = NULL,
decimals = 2,
decimals_p = 3,
confidence = FALSE
)
t_object |
An object of class "htest" returned by
|
d_object |
An effect size table returned by
|
decimals |
How many decimals should be printed for the t-value (defaults to 2). |
decimals_p |
How many decimals should be printed for the p-value (defaults to 3). |
confidence |
Logical. Whether a confidence interval for the effectsize
should be printed or not. Can only be |
To use this function, you need to install the R package effectsize
to compute Cohen's d; pass this object as the second argument.
A string describing the t-test; to be included in an R markdown document.
Martin Papenberg martin.papenberg@hhu.de
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsale, NJ: Lawrence Erlbaum.
ttest <- t.test(1:10, y = c(7:20), var.equal = TRUE)
library("effectsize") # for Cohen's d
cohend <- cohens_d(1:10, c(7:20))
print_ttest(ttest, cohend) # include this call in Rmd inline code
# An example for paired data:
data(sleep) # ?sleep
tt <- t.test(sleep$extra[sleep$group == 1],
sleep$extra[sleep$group == 2], paired = TRUE)
cd <- cohens_d(sleep$extra[sleep$group == 1],
sleep$extra[sleep$group == 2], paired = TRUE)
print_ttest(tt, cd)
# Print the confidence interval
print_ttest(tt, cd, confidence = TRUE)
# The information about the CI is taken from the effectsize object:
cd <- cohens_d(sleep$extra[sleep$group == 1],
sleep$extra[sleep$group == 2], paired = TRUE, ci = .8)
print_ttest(tt, cd, confidence = TRUE)
# effect size object can be left out:
print_ttest(tt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.