slcor | R Documentation |
Calculates the pairwise Pearson correlation between all columns
within a fixed window size (win
)
using the use = "pairwise.complete.obs"
option
from cor()
. That is, the correlation
between each pair of variables is computed using all complete pairs
of observations on those variables.
slcor(x, win = 1L)
x |
A numeric matrix. The variables index the columns. |
win |
The size of the window. Defaults to 1. |
A correlation matrix with only the observations within a window containing calculated correlations.
David Gerard
set.seed(1) n <- 10 p <- 100 xmat <- matrix(rnorm(n * p), ncol = n) xmat[sample(n * p, size = 30)] <- NA_real_ slcor(xmat, win = 2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.