knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
Correlation networks based on a correlation threshold can easily be built using the corrr
and ggraph
packages. Unfortunately the use a p-value threshold was not as straightforward. This package makes it easy to create correlation networks based on either correlation thresholds or p-value thresholds.
You can install cornet from github with:
# install.packages("devtools") devtools::install_github("blasern/cornet")
Let's have a look at a correlation network for the mtcars
dataset.
require(cornet) require(ggraph) data('mtcars') graph_cors <- correlation_network(mtcars, correlation_method = 'pearson', threshold = 0.05, threshold_method = 'pvalue', adjust = 'holm') set.seed(42) ggraph(graph_cors, layout = "graphopt") + geom_edge_link(aes(color = r), width = 1.3) + geom_node_label(aes(label = name)) + scale_edge_colour_gradient2(limits = c(-1, 1)) + theme_graph()
If you find issues, please let me know. If you would like to contribute, please create a pull request.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.