cor.testDT | R Documentation |
Compute pairwise correlation between multiple outcomes. Can reorder the outcomes according to a clustering of the obtained correlations.
cor.testDT(
data,
format,
col.value = NULL,
col.group = NULL,
lower.tri = TRUE,
upper.tri = FALSE,
method.cor = "cor.test",
use.pairwiseNNA = TRUE,
reorder = "AOE",
imput.value = 0,
hclust.method = "complete",
trace = TRUE,
plot = TRUE,
args.plot = list(),
output = "data.table",
...
)
data |
the dataset. |
format |
[character] the format of data. Can be |
col.value |
[character vector] columns containing the values to be analyzed.
In wide format, all the columns will be used if |
col.group |
[character] column defining the groups of observations between which the correlation will be computed. |
lower.tri |
[logical] should only the lower triangle of the matrix be filled? |
upper.tri |
[logical] should only the upper triangle of the matrix be filled? |
method.cor |
[character] the method used to compute the correlation.
Must at least have |
use.pairwiseNNA |
[logical]] If |
reorder |
[character] argument order of corrMatOrder. If |
imput.value |
[numeric] the value to be used in the clustering algorithm in place of NA. Can be a number or an operator (e.g. median). |
hclust.method |
[character] argument hclust.method of corrMatOrder. |
trace |
[logical] should the progression of the computation of the correlation be displayed. logical. |
plot |
[logical] should the correlation matrix be displayed. logical. |
args.plot |
[list] arguments to be passed to |
output |
[character] how to output the correlation value. Can be |
... |
additional arguments to be passed to method.cor. |
data must be coercible to data.table.
If data="wide"
each column correspond to a different outcomes, indicated by argument names.
If data="long"
then the first value of names is used to define the outcomes and the seconde is used to define their values.
method.cor can be any method but its first two arguments, named x and y, will be given the values of the outcomes.
If imput.value is an operator then it is applied on the values in the same line or column.
This function uses the function ggHeatmap
to display the correlation matrix.
An object determined by the output argument
ggHeatmap
to display the correlation matrix
M <- matrix(rnorm(1e3),100,10)
## display correlation matrix with color
cor.testDT(M, format = "wide")
## display correlation matrix with color and text
cor.testDT(M, format = "wide",
args.plot = list(add.text = "correlation", round = 1))
## use spearman instead of pearson
cor.testDT(M, format = "wide", method.cor = function(x,y,...){cor.test(x,y,method = "spearman")},
args.plot = list(add.text = "correlation", round = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.