correlate {CPC} | R Documentation |
Calculates correlation coefficient between two variables and returns a list containing the correlation estimate, its standard error, the p-value of a null-hypothesis significance test, and the number of observations used.
correlate(x, y, ...)
x |
a numeric vector. |
y |
a numeric vector. |
... |
arguments passed to |
Additional arguments to alter the type of null hypothesis significance test, the method used to
calculate the correlation coefficient, the confidence level, or other options should be passed to
correlate
() and will be inherited by cor.test()
. Note that unlike
cor.test()
, both arguments x
and y
are required.
Returns a list with elements containing the correlation coefficient estimate, its associated standard error, the p-value of a null-hypothesis significance test, and the number of observations used, all as numeric vectors of length 1.
data <- matrix(c(rnorm(50, 0, 1), rnorm(50, 5, 1)), ncol = 2, byrow = TRUE)
correlate(data[, 1], data[, 2])