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.449 feature.208 feature.956 feature.903 feature.674 feature.322
#> 0.08571429 0.65714286 0.60000000 -0.14285714 0.48571429 -0.08571429