View source: R/mathematical_functions.R
cor2 | R Documentation |
Correlation function with safe-guards against errors
cor2(
x,
y = NULL,
use = "everything",
method = c("pearson", "kendall", "spearman")
)
x |
a numeric vector, matrix or data frame. |
y |
|
use |
an optional character string giving a
method for computing covariances in the presence
of missing values. This must be (an abbreviation of) one of the strings
|
method |
a character string indicating which correlation
coefficient (or covariance) is to be computed. One of
|
The value of cor
if successful,
otherwise NA
.
If x
is a two-dimensional object and y
is
NULL
(or missing), then the correlation between the first and second
column of x
is calculated – unlike cor
which
calculates all pairwise correlations among all columns of x
.
x <- sample(10)
x <- data.frame(
val1 = x,
val2 = x + stats::rnorm(10, 0, 1)
)
cor2(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.