Returns the correlation and p-value for two variables using a user-specified correlation metric. P-values are estimated analytically, not via permutation-testing.
Usage
get.correlation.p.and.corr(x, y, alternative = 'two.sided', method = 'pearson');
Arguments
- x
Vector of numbers to analyze
- y
Vector of numbers to analyze
- alternative
What is the null-hypothesis?
- method
The correlation technique to use (passed directly to cor.test)
Value
Returns a two-element vector containing the correlation and its p-value.
Examples
get.correlation.p.and.corr(
x = runif(100),
y = runif(100),
method = 'pearson'
);
#> [1] -0.02419819 0.81112527
get.correlation.p.and.corr(
x = sample(1:10, 100, replace = TRUE),
y = runif(100),
method = 'spearman'
);
#> [1] 0.02637574 0.79448844