All functions in this package are deprecated. Please use the
{cocoon}
package instead.
With format_corr()
you can format correlation statistics generated from
cor.test()
output. This detects whether the object is from a Pearson,
Kendall, or Spearman correlation and reports the appropriate correlation
label (r, τ, ρ). The default output is APA formatted, but numbers of digits,
leading zeros, the presence of confidence intervals, and italics are all
customizable.
Usage
format_corr(
x,
digits = 2,
pdigits = 3,
pzero = FALSE,
ci = TRUE,
italics = TRUE,
type = "md"
)
Arguments
- x
Correlation object
- digits
Number of digits after the decimal for means, confidence intervals, and correlation coefficients
- pdigits
Number of digits after the decimal for p-values, ranging between 1-5 (also controls cutoff for small p-values)
- pzero
Logical indicator of whether to include leading zero for p-values
- ci
Logical indicator of whether to print 95% confidence intervals
- italics
Logical for whether p label should be italicized
- type
Type of formatting ("md" = markdown, "latex" = LaTeX)
Examples
# Prepare data
mtcars_corr <- cor.test(mtcars$mpg, mtcars$disp)
# Print statistics
format_corr(mtcars_corr)
#> Warning: `format_corr()` was deprecated in formatstats 0.0.0.9000.
#> ℹ Please use `cocoon::format_corr()` instead.
#> Warning: `format_p()` was deprecated in formatstats 0.0.0.9000.
#> ℹ Please use `cocoon::format_p()` instead.
#> ℹ The deprecated feature was likely used in the formatstats package.
#> Please report the issue at
#> <https://github.com/JeffreyRStevens/formatstats/issues>.
#> [1] "_r_ = -.85, 95% CI [-0.92, -0.71], _p_ < .001"
# Change digits
format_corr(mtcars_corr, digits = 3)
#> [1] "_r_ = -.848, 95% CI [-0.923, -0.708], _p_ < .001"
# Change cutoff digits for p-value
format_corr(mtcars_corr, pdigits = 2)
#> [1] "_r_ = -.85, 95% CI [-0.92, -0.71], _p_ < .01"
# Add leading zero to p-value and don't print confidence intervals
format_corr(mtcars_corr, pzero = TRUE, ci = FALSE)
#> [1] "_r_ = -0.85, _p_ < 0.001"