fastcor: Fast Pearson Correlation

View source: R/main.R

fastcorR Documentation

Fast Pearson Correlation

Description

Centers and normalizes rows (or columns when byrow = FALSE) and then computes Pearson correlations using fast matrix cross-products. This function does not rank-transform the inputs and therefore does not compute Spearman correlation.

Usage

fastcor(a, b = NULL, byrow = TRUE, diag = TRUE, n.cores = NULL)

Arguments

a

Numeric matrix.

b

Optional numeric matrix with the same row or column orientation as a.

byrow

Logical; when TRUE, rows are correlated. When FALSE, columns are correlated.

diag

Logical; when b is supplied and diag = TRUE, return only the pairwise diagonal correlations between matching rows (or columns).

n.cores

Number of CPU cores requested for the compiled matrix operations. An explicit value takes precedence over options(n.cores = ...).

Value

A correlation matrix, or a numeric vector of diagonal correlations when b is supplied with diag = TRUE.

Author(s)

Stefano Cacciatore, Leonardo Tenori, Dupe Ojo, Alessia Vignoli

See Also

pls.single.cv, pls.double.cv

Examples

data(iris)
x <- as.matrix(iris[1:10, -5])
fastcor(x)

fastPLS documentation built on Sept. 29, 2026, 1:06 a.m.