correlation: Correlation

correlationR Documentation

Correlation

Description

Correlation

Usage

correlation(x, y, ...)

## S4 method for signature 'Matrix,Matrix'
correlation(x, y, method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'Matrix,missingOrNULL'
correlation(x, y = NULL, method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'SummarizedExperiment,SummarizedExperiment'
correlation(x, y, i = 1L, method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'SummarizedExperiment,missingOrNULL'
correlation(
  x,
  y = NULL,
  i = 1L,
  j = NULL,
  method = c("pearson", "kendall", "spearman")
)

## S4 method for signature 'matrix,matrix'
correlation(x, y, method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'matrix,missingOrNULL'
correlation(x, y = NULL, method = c("pearson", "kendall", "spearman"))

## S4 method for signature 'numeric,numeric'
correlation(x, y, method = c("pearson", "kendall", "spearman"))

Arguments

x

Object.

y

Object.

method

character(1). Which correlation coefficient (or covariance) is to be computed. See stats::cor documentation for details.

i

integer(1) or character(1). For SummarizedExperiment, primary assay.

j

integer(1), character(1), or NULL. For SummarizedExperiment, optional secondary assay. If NULL, calculates correlation matrix only on the primary assay.

...

Additional arguments.

Value

numeric(1) or matrix.

Note

Updated 2021-06-04.

See Also

  • stats::cor().

  • stats::cor.test().

  • stats::sd().

  • https://stats.stackexchange.com/questions/24980

Examples

data(correlation, package = "AcidTest")
list <- correlation

## vector ====
x <- list[["vector_x"]]
y <- list[["vector_y"]]

head(x)
head(y)

correlation(x = x, y = y)

## matrix ====
x <- list[["matrix_x"]]
y <- list[["matrix_y"]]

head(x)
head(y)

stats::cor(x)
correlation(x)

stats::cor(x = c(x), y = c(y))
correlation(x = x, y = y)

## SummarizedExperiment ====
x <- list[["SummarizedExperiment_x"]]
y <- list[["SummarizedExperiment_y"]]

correlation(x = x, i = 1L)
correlation(x = x, i = 1L, j = 2L)
correlation(x = x, y = y)

acidgenomics/r-acidexperiment documentation built on Jan. 17, 2024, 7:56 p.m.