Skip to contents

Allows to run cor.test on a matrix of inputs.

Usage

cor_fast(
  x,
  y = NULL,
  use = "everything",
  method = "pearson",
  alternative = "two.sided",
  continuity = FALSE,
  return_matrix = TRUE
)

Arguments

x

a numeric vector, matrix, or data frame.

y

NULL (default) or a vector.

use

an optional character string giving a method for computing correlations in the presence of missing values. This must be (an abbreviation of) one of the strings "everything", "all.obs", "complete.obs", or "pairwise.complete.obs".

method

which correlation method to use, "pearson" or "spearman"

alternative

how to perform the statistical test

continuity

should a continuity correction be applied

return_matrix

should the matrices of values be returned, or a long data.frame

Value

a list of matrices, rho, pvalue, or a data.frame.

Details

Although the interface is mostly identical to the built-in stats::cor.test() method, there are some differences.

  • if only x is provided as a matrix, the columns must be named.

  • if providing both x and y, it is assumed they are both single vectors.

  • if NA values are present, this function does not error, but will either remove them or return NA, depending on the option.

  • "na.or.complete" is not a valid option for use.

  • A named list with matrices or data.frame is returned, with the rho and pvalue values.