Selects n random rows from a numeric matrix with replacement. For each random row, permute vector y and perform correlation.
Examples
# generate example data
X <- matrix(runif(1e3 * 6), nrow = 1e3, ncol = 6)
y <- 1:6
dimnames(X) <- list(paste("feature", 1:1e3, sep = "."), paste("sample", 1:6, sep = "."))
# sample random correlations from permuted data
null_dist <- sample_n_random_cor(X, y, n = 1e3, method = "spearman")
head(null_dist)
#> feature.333 feature.718 feature.797 feature.335 feature.122 feature.71
#> -0.42857143 -0.20000000 -0.42857143 -0.08571429 -0.48571429 0.77142857