epi_stats_corr_triangle: Get the lower triangle from a correlation matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/epi_stats_corr_triangle.R

Description

Keep only the lower triangle of the correlation matrix Useful to create a nicer heatmap. Requires the original, unmelted correlation matrix with both correlation (r) and p-values (P).

Usage

1
epi_stats_corr_triangle(cormat = "cormat_all$cormat")

Arguments

cormat

a matrix object (usually the output of Hmisc::rcorr() or episcout::epi_stats_corr()). Default 'cormat_all$cormat'

Value

Returns a list object melted_triangles containing the lower triangle of the correlation matrix (cormat) with the correlation (cormat_melted_triangle_r) and p-values (cormat_melted_triangle_pval).

Author(s)

Antonio Berlanga-Taylor <https://github.com/AntonioJBT/episcout>

See Also

epi_stats_corr, epi_stats_corr_rename, epi_plot_heatmap, epi_plot_heatmap_triangle, rcorr, melt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
df <- data.frame(var_id = rep(1:(n / 2), each = 2),
var_to_rep = rep(c("Pre", "Post"), n / 2),
x = rnorm(n),
y = rbinom(n, 1, 0.50),
z = rpois(n, 2)
)
epi_clean_count_classes(df)
df_corr <- df %>%select_if(~ epi_clean_cond_numeric(.))
df_corr <- df_corr[, -1] # exclude var_id
cormat_all <- epi_stats_corr(df_corr, method = 'pearson')
melted_triangles <- epi_stats_corr_triangle(cormat = cormat_all$cormat)
melted_triangles$cormat_melted_triangle_r
melted_triangles$cormat_melted_triangle_pval
class(melted_triangles)

## End(Not run)

AntonioJBT/episcout documentation built on Nov. 7, 2019, 5:34 p.m.