Description Usage Arguments Details Value Author(s) References See Also Examples
A faster, onestep calculation of Student correlation pvalues for multiple correlations, properly taking into account the actual number of observations.
1 2 3 4  corAndPvalue(x, y = NULL,
use = "pairwise.complete.obs",
alternative = c("two.sided", "less", "greater"),
...)

x 
a vector or a matrix 
y 
a vector or a matrix. If 
use 
determines handling of missing data. See 
alternative 
specifies the alternative hypothesis and must be (a unique abbreviation of) one of

... 
other arguments to the function 
The function calculates correlations of a matrix or of two matrices and the corresponding Student pvalues.
The output is not as fullfeatured as cor.test
, but can work with matrices as input.
A list with the following components, each a matrix:
cor 
the calculated correlations 
p 
the Student pvalues corresponding to the calculated correlations 
Z 
Fisher transforms of the calculated correlations 
t 
Student t statistics of the calculated correlations 
nObs 
Numbers of observations for the correlation, pvalues etc. 
Peter Langfelder and Steve Horvath
Peter Langfelder, Steve Horvath (2012) Fast R Functions for Robust Correlations and Hierarchical Clustering. Journal of Statistical Software, 46(11), 117. https://www.jstatsoft.org/v46/i11/
cor
for calculation of correlations only;
cor.test
for another function for significance test of correlations
1 2 3 4 5 6 7 8 9 10 11  # generate random data with nonzero correlation
set.seed(1);
a = rnorm(100);
b = rnorm(100) + a;
x = cbind(a, b);
# Call the function and display all results
corAndPvalue(x)
# Set some components to NA
x[c(1:4), 1] = NA
corAndPvalue(x)
# Note that changed number of observations.

Loading required package: dynamicTreeCut
Loading required package: fastcluster
Attaching package: 'fastcluster'
The following object is masked from 'package:stats':
hclust
==========================================================================
*
* Package WGCNA 1.61 loaded.
*
sh: 1: wc: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: wc: Permission denied
sh: 1: cannot create /dev/null: Permission denied
sh: 1: wc: Permission denied
sh: 1: cannot create /dev/null: Permission denied
* Important note: It appears that your system supports multithreading,
* but it is not enabled within WGCNA in R.
* To allow multithreading within WGCNA with all available cores, use
*
* allowWGCNAThreads()
*
* within R. Use disableWGCNAThreads() to disable threading if necessary.
* Alternatively, set the following environment variable on your system:
*
* ALLOW_WGCNA_THREADS=<number_of_processors>
*
* for example
*
* ALLOW_WGCNA_THREADS=2
*
* To set the environment variable in linux bash shell, type
*
* export ALLOW_WGCNA_THREADS=2
*
* before running R. Other operating systems or shells will
* have a similar command to achieve the same aim.
*
==========================================================================
Attaching package: 'WGCNA'
The following object is masked from 'package:stats':
cor
$cor
a b
a 1.0000000 0.6836311
b 0.6836311 1.0000000
$p
a b
a 0.000000e+00 4.583225e15
b 4.583225e15 0.000000e+00
$Z
a b
a Inf 8.274985
b 8.274985 Inf
$t
a b
a Inf 9.272878
b 9.272878 Inf
$nObs
a b
a 100 100
b 100 100
$cor
a b
a 1.0000000 0.6699188
b 0.6699188 1.0000000
$p
a b
a 0.00000e+00 8.40745e14
b 8.40745e14 0.00000e+00
$Z
a b
a Inf 7.859018
b 7.859018 Inf
$t
a b
a Inf 8.748388
b 8.748388 Inf
$nObs
a b
a 96 96
b 96 100
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.