Learn R Programming

CPC (version 2.6.2)

correlate: Test for Bivariate Correlation

Description

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.

Usage

correlate(x, y, ...)

Value

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.

Arguments

x

a numeric vector.

y

a numeric vector.

...

arguments passed to cor.test().

Details

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.

Examples

Run this code
data <- matrix(c(rnorm(50, 0, 1), rnorm(50, 5, 1)), ncol = 2, byrow = TRUE)

correlate(data[, 1], data[, 2])

Run the code above in your browser using DataLab