Skip to contents

This function computes the Spearman's correlation for each row vector in x. See the Details section below for further information.

Usage

rowSpearmanCor(
  x,
  y,
  alternative = c("two.sided", "greater", "less"),
  conf.level = 0.95,
  ...
)

Arguments

x

matrix or data.frame.

y

numeric vector of data values. Must have the same length as ncol(x).

alternative

character string indicating the alternative hypothesis for each row of x. It must be one of "two.sided" (default), "greater" or "less".

conf.level

numerical value or numeric vector of length nrow(x). The confidence levels of the intervals. All values must be in the range of \([0:1]\) or NA.

...

further arguments to cor.test

Value

A list containing two elements:

statistic

A numeric vector, the values of the test statistic

significance

A numeric vector, the p-values of the selected test

Details

It is a wrapper to cor.test function.

Author

Alessandro Barberis

Examples

#Seed
set.seed(1010)

#Data
x = matrix(rnorm(100 * 20), 100, 20)
y = rnorm(20)

#Compute
rowSpearmanCor(x = x, y = y)
#> $statistic
#>   [1] 1550 1002 1048 1334 1772 1064  836 1384 1482 1944 1042 1398 2118 1072 1044
#>  [16] 2020 1650 1192 1708 1672 1962 1156 1044 1218 1720 1172 1440 1392 1218 1324
#>  [31] 1388  998 1818 1614 1102 1260 1478 1048 1782 1562 1254 1374 1496 1192 1428
#>  [46] 1278 1586 1304 1400  906 1352 1976  856 1278 1324 1656  932 1392 1700 1338
#>  [61] 1080 1006  864 1288 1380 1448 1192 1546 1016 1178  738 1442 1624 1202 1298
#>  [76] 1550 1148 1374 1172 1644 1100 2086  990 1218 1374 1106 1884 1986 1184  818
#>  [91]  818 1614  854  932 1798 1300 1526 1404 1664 1754
#> 
#> $significance
#>   [1] 0.484202379 0.293205108 0.367829058 0.992391679 0.152315540 0.396168703
#>   [7] 0.107575160 0.866179629 0.630454425 0.041987538 0.357515292 0.831278236
#>  [13] 0.006888333 0.410789108 0.360934072 0.020559898 0.305443868 0.662617486
#>  [19] 0.223791737 0.272540640 0.035780800 0.581232598 0.360934072 0.723888577
#>  [25] 0.208932277 0.616864796 0.728677101 0.846201667 0.723888577 0.987319786
#>  [31] 0.856179824 0.287203118 0.112171039 0.364372006 0.468215881 0.826316171
#>  [37] 0.639580201 0.367829058 0.142825467 0.460326820 0.811469747 0.891264115
#>  [43] 0.598935898 0.662617486 0.757611736 0.871187188 0.414490572 0.936659068
#>  [49] 0.826316171 0.170512887 0.946778134 0.031475535 0.123454784 0.871187188
#>  [55] 0.987319786 0.296235458 0.199406427 0.846201667 0.234081771 0.982248374
#>  [61] 0.425705285 0.299285372 0.130262923 0.896294086 0.876199602 0.709584427
#>  [67] 0.662617486 0.492298434 0.314828152 0.630454425 0.050690771 0.723888577
#>  [73] 0.347374223 0.685958524 0.921498955 0.484202379 0.563763030 0.891264115
#>  [79] 0.616864796 0.314828152 0.464262599 0.010089051 0.275434002 0.723888577
#>  [85] 0.891264115 0.476174627 0.068967376 0.028661115 0.644162476 0.094622879
#>  [91] 0.094622879 0.364372006 0.121794087 0.199406427 0.128535931 0.926549607
#>  [97] 0.533776867 0.816411747 0.284231482 0.170512887
#>