View source: R/epi_stats_corr_triangle.R
epi_stats_corr_triangle | R Documentation |
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).
epi_stats_corr_triangle(cormat = "cormat_all$cormat")
cormat |
a matrix object (usually the output of Hmisc::rcorr() or episcout::epi_stats_corr()). Default 'cormat_all$cormat' |
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).
Antonio Berlanga-Taylor <\url{https://github.com/AntonioJBT/episcout}>
epi_stats_corr
, epi_stats_corr_rename
,
epi_plot_heatmap
, epi_plot_heatmap_triangle
,
rcorr
, melt
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.