Report correlation result in text
Value
a string with the formatted correlation result for use inline in an R Markdown or Quarto document
Examples
results <- mtcars |> cor_test(mpg, wt)
report_cor(results)
#> Warning: Unknown or uninitialised column: `df`.
#> [1] "*r*~()~ = -0.87, *p* < 0.0001"
results2 <- mtcars |>
dplyr::group_by(cyl) |>
cor_test(mpg, wt, method = "spearman")
report_cor(results2, effect = 2)
#> [1] "$\\rho$ = -0.65, *S* = 92.7, *p* = 0.111"
results3 <- mtcars |>
cor_test(
vars = "mpg",
vars2 = c("disp", "hp", "drat"),
method = "kendall"
)
report_cor(results3, effect = c("mpg", "disp"))
#> [1] "*$\\tau$* = -0.77, *T* = -6.11, *p* < 0.0001"
