summarise_correlation {tidySummaries} | R Documentation |
Summarise Correlation Matrix with Optional Significance Tests
Description
Computes correlations between numeric variables of a data frame, or between two vectors. Optionally tests statistical significance (p-value)
Usage
summarise_correlation(
x,
y = NULL,
method = c("pearson", "kendall", "spearman"),
cor_test = FALSE
)
Arguments
x |
A numeric vector, matrix, data frame, or tibble. |
y |
Optional. A second numeric vector, matrix, or data frame (same dimensions as 'x'). |
method |
Character. One of "pearson" (default), "kendall", or "spearman". |
cor_test |
Logical. If TRUE, uses 'cor.test()' and includes p-values. If FALSE, uses 'cor()' only. |
Value
A tibble with variables, correlations, and optionally p-values. Significant results (p < 0.05) are printed in red in the console.
Examples
summarise_correlation(iris)
summarise_correlation(iris$Sepal.Length, iris$Petal.Length, cor_test = TRUE)
[Package tidySummaries version 0.1.0 Index]