corr | R Documentation |
Efficiently fit correlation coefficient for matrix or two vectors
corr(x, y = NULL, spearman = FALSE)
x |
a matrix or vector |
y |
a vector. Optional. |
spearman |
Logical. Use Spearman's correlation? |
a numeric vector, the correlation coefficient
library(dplyr)
# fit for entire data set
iris %>%
select_if(is.numeric) %>%
corr()
# just fit for two vectors
corr(iris$Sepal.Length, iris$Sepal.Width)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.