Description Usage Arguments Value Note Author(s) See Also Examples
Reformat correlation matrix from cor
into variable-pair format, with options to calulate statistical significance and confidence intervals and sort results by required result attribute.
1 | cor.results(cormat, sort.by="r", data=NULL, var.name=NULL)
|
cormat |
A matrix of correlation results returned from the |
sort.by |
Specify what order variable-pairs are reported in. Default value of “ |
data |
Default = |
var.name |
Default = |
Returns a data frame identifying the names of each variable pair, the correlation between them and, optionally, the associted p-value, significance level and confidence intervals.
Borrows heavily from http://www.sthda.com/english/wiki/correlation-matrix-an-r-function-to-do-all-you-need
Paul Williamson
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## Generate correlation matrix using the function cor( )
res <- cor(survey[, 8:11]) # use continuous variables only
## convert correlation matrix into 'variable-pair' format
cor.results(res)
## Sort results as required
cor.results(res, sort.by = "abs.r") # by absolute value of r
cor.results(res, sort.by = "x") # by names of 'x' variables
cor.results(res, sort.by = "y") # by names of 'y' variables
## Calculate and report p-value, significance level and confidence intervals
cor.results(res, data = survey[, 8:11])
## Report results for variable pairs involving a specific variable
cor.results(res, var.name="Height")
## Combine elements of function as required
cor.results(res, data = survey[ , 8:11], var.name="Height", sort.by = "p.value")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.