# Prepare statistical objects
test_corr <- cor.test(mtcars$mpg, mtcars$cyl)
test_corr2 <- cor.test(mtcars$mpg, mtcars$cyl, method = "kendall")
test_ttest <- t.test(mtcars$vs, mtcars$am)
test_ttest2 <- wilcox.test(mtcars$vs, mtcars$am)
# Format correlation
format_stats(test_corr)
# Remove confidence intervals and italics
format_stats(test_corr, full = FALSE, italics = FALSE)
# Change digits and add leading zero to p-value
format_stats(test_corr, digits = 3, pdigits = 4, pzero = TRUE)
# Format Kendall's tau
format_stats(test_corr2)
# Format t-test
format_stats(test_ttest)
# Remove mean and confidence interval
format_stats(test_ttest, full = FALSE)
# Remove degrees of freedom and spell out "Mean"
format_stats(test_ttest, dfs = "none", mean = "word")
# Format for LaTeX
format_stats(test_ttest2, type = "latex")
Run the code above in your browser using DataLab