Description Usage Arguments Details Value Author(s) Examples
Tests for association between each paired variables:
Using pearson's chi-squared test (chisq.test function from stats package).
Using correlation test (cor.test function from stats package).
Using analysis of variance model (aov function from stats package).
Also adjusts p.values using Benjamini & Hochberg method (p.adjust function from stats package) and constructs heatmap using heatmaply function.
1 |
data |
a dataframe. It is strongly recommended that the dataframe has no missing data and is preprocessed. |
vars |
a list including the name (or index) of columns of data. |
levels |
An integer value indicating the maximum number of levels of a categorical variable. To be used to distinguish the categorical variable. Defaults to NULL because it is supposed that |
plot |
Logical indicating if the heatmap should be constructed. Defaults to FALSE. |
This provides a wrapper to chisq.test
, cor.test
, aov
, p.adjust
from stats
package to test association between variables
And a wrapper to heatmaply
package to construct heatmap.
If plot = FALSE, returns a matrix containing p.values of tests between each two variables. Otherwise returns A list which contains:
matrix |
A matrix containing p.values of tests between each two variables. |
heatmap |
A plotly object containing heatmap related to matrix. |
Elyas Heidari
1 2 3 4 5 6 7 8 9 10 | data("NHANES")
## Using raw data
df <- NHANES[1:1000, ]
test_matrix <- test_assoc(data = df, vars = colnames(df), plot = FALSE, levels = 15)
## Using preprocessed data
data <- data_preproc(NHANES, levels = 15)
data$SEQN <- NULL
## Outputs the heatmap too (plot = TRUE)
test_mat_heatmap <- test_assoc(data = data, vars = colnames(data[, 1:20]), plot = TRUE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.