Skip to contents

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

Usage

rowPearsonCor(
  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 or vector of length nrow(x). The alternative hypothesis for each row of x. Values 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.

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 row_cor_pearson function.

Author

Alessandro Barberis

Examples

#Seed
set.seed(1010)

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

#Compute
rowPearsonCor(x = x, y = y)
#> $statistic
#>   [1] -1.562687801  0.858321163  0.637163042  0.128135983 -0.862080975
#>   [6]  0.598241121  1.212132923  0.069343265  0.456858601 -1.898899711
#>  [11]  0.184459567 -0.339190941 -3.007207334  0.336614733  0.617155315
#>  [16] -2.481769120 -0.861755878  0.455952916 -0.949161902 -1.068207821
#>  [21] -1.907514254  0.108342487  0.853011464  0.394641243 -0.975175694
#>  [26]  0.864453082 -0.276135713  0.397042009  0.135430056 -0.462988385
#>  [31] -0.361123747  1.461778755 -0.511219918 -1.082653209  0.004997978
#>  [36]  0.479980846 -0.828477145  1.318518418 -1.782204536 -0.998935926
#>  [41]  0.811267590  0.778846860  0.063646496  0.807429722 -0.287617366
#>  [46]  0.229086538 -0.614220396  0.407021288  0.548241677  1.311804083
#>  [51]  1.083779739 -1.889587922  0.546321065  0.100801842  0.101202574
#>  [56] -2.561201443  1.583823429 -0.730766741 -1.048014217 -0.319427625
#>  [61]  0.579442956  0.862395912  1.496058535 -0.397273649 -0.474920610
#>  [66] -0.235018504  0.728067837 -0.876637740  0.034058214  0.550229079
#>  [71]  2.323603386 -1.613238444 -1.424067416 -0.119842224  0.400028195
#>  [76] -0.809365837  0.194148780  0.353125443 -0.662352249 -0.767740894
#>  [81] -0.007011127 -2.543693293  0.726090012  0.420845627 -0.732734821
#>  [86]  0.724719987 -1.240322324 -2.395388623  0.245192102  0.731896295
#>  [91]  1.163954688 -0.976294907  1.556730531  1.753549523 -1.007125364
#>  [96] -0.408247435 -0.468959552 -0.592881300 -1.119771117 -1.314586148
#> 
#> $significance
#>   [1] 0.135536058 0.402000439 0.532039815 0.899462121 0.399982690 0.557132482
#>   [7] 0.241132739 0.945480943 0.653237919 0.073727039 0.855715230 0.738391072
#>  [13] 0.007565871 0.740300062 0.544860776 0.023168646 0.400156896 0.653876795
#>  [19] 0.355108974 0.299544083 0.072539393 0.914922608 0.404861217 0.697744610
#>  [25] 0.342397511 0.398713075 0.785589293 0.696004803 0.893774879 0.648921201
#>  [31] 0.722210668 0.161041167 0.615410709 0.293253139 0.996067183 0.637021871
#>  [37] 0.418250745 0.203861755 0.091592575 0.331066169 0.427809764 0.446188963
#>  [43] 0.949953191 0.429960192 0.776924829 0.821384399 0.546755396 0.688791618
#>  [49] 0.590261338 0.206071641 0.292766609 0.075030171 0.591553341 0.920822078
#>  [55] 0.920508440 0.019634212 0.130645338 0.474327179 0.308501179 0.753079743
#>  [61] 0.569472138 0.399813976 0.151966290 0.695837027 0.640554996 0.816847228
#>  [67] 0.475937508 0.392233089 0.973205569 0.588925893 0.032056824 0.124086665
#>  [73] 0.171532459 0.905935620 0.693843169 0.428874501 0.848233670 0.728096097
#>  [79] 0.516137234 0.452595599 0.994483097 0.020366462 0.477119661 0.678849812
#>  [85] 0.473154954 0.477939550 0.230781390 0.027687610 0.809081343 0.473654184
#>  [91] 0.259639152 0.341857780 0.136941960 0.096519592 0.327222224 0.687907437
#>  [97] 0.644728453 0.560636387 0.277531110 0.205153701
#>