cor

Correlation

Computes the correlation coefficient between two vectors. method = "pearson" (default) is the linear correlation. method = "spearman" ranks values first (average ranks for ties), then computes Pearson on ranks.

Parameters

Returns

The correlation coefficient (-1 to 1).

Examples

cor(mtcars["mpg"], mtcars["wt"])