| corr | R Documentation |
Computes Pearson, Spearman, or Kendall correlations from variables in a data
frame. With data = NULL, the active data set is used.
corr(
...,
data = NULL,
method = c("pearson", "spearman", "kendall"),
missing = c("pairwise", "listwise"),
sig = FALSE,
obs = FALSE,
ci = FALSE,
star = FALSE,
level = 0.95,
digits = 3,
p_digits = 3,
show = TRUE,
console = FALSE
)
... |
Numeric variables. If omitted, all numeric variables are used. |
data |
Data frame or |
method |
Correlation method. |
missing |
Pairwise or listwise deletion. |
sig |
Show a p-value matrix. |
obs |
Show a matrix of pairwise sample sizes. |
ci |
Show pairwise confidence intervals where available. |
star |
Add significance stars to the displayed correlation matrix. |
level |
Confidence level. |
digits, p_digits |
Decimal places. |
show |
Logical; open the formatted result in the Viewer. Default |
console |
Logical; also print the traditional result in the Console. Default |
An object of class r4vn_stat, returned invisibly. Its sections
component contains the formatted correlation matrix and any requested
p-value, pairwise sample-size, or confidence-interval tables. Its raw
component contains the numeric correlation (correlation), p-value
(p.value), and pairwise sample-size (n) matrices plus the selected
correlation method; call records the matched function call.
# Extended usage examples
d <- data.frame(age = c(20, 25, 30, 35, 40, 45),
bmi = c(20, 22, 24, 23, 26, 28),
score = c(60, 65, 68, 72, 75, 80))
corr(age, bmi, score, data = d, show = FALSE)
corr(age, bmi, score, data = d, method = "spearman", show = FALSE)
corr(age, bmi, score, data = d, sig = TRUE, obs = TRUE, ci = TRUE, show = FALSE)
corr(age, bmi, score, data = d, star = TRUE, show = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.