cor_network: Tidy co-occurrence network data

Description Usage Arguments Value Author(s) Examples

View source: R/cor-network.R

Description

The function calculates correlation coefficient, statistical significance level and filters according to conditions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
cor_network(
  corr,
  p.value = NULL,
  directed = FALSE,
  row.names = NULL,
  col.names = NULL,
  rm.dup = TRUE,
  simplify = TRUE,
  weight = NULL,
  r.thres = 0.6,
  r.abs = TRUE,
  p.thres = 0.05,
  val.type = "tbl_graph"
)

## S3 method for class 'cor_network'
print(x, n = 3, ...)

Arguments

corr

correlation matrix.

p.value

significant matrix of correlation.

directed

logical value, whether or not to create a directed graph.

row.names, col.names

row and column names of correlation matrix.

rm.dup

logical (defaults to TRUE) indicating whether remove duplicate rows. If TRUE, the correlation between A-B and B-A is retained only A-B.

simplify

logical value (defaults to TRUE) indicating whether to delete nodes without edge connections.

weight

NULL (default) or name of column in edges which will be renamed to "weight".

r.thres

a numeric value.

r.abs

logical value (defaults to TRUE).

p.thres

a numeric value.

val.type

type return value:

  • tbl_graph: return tbl_graph object

  • igraph: return igraph object

  • list: return a list of nodes and edges

x

a cor_network object.

n

number of rows to show.

...

extra params for printing.

Value

a tbl_graph (default), igraph or list of nodes and edges.

Author(s)

Houyun Huang, Lei Zhou, Jian Chen, Taiyun Wei

Examples

1
2
3
4
5
6
7
8
9
cor_network(cor(mtcars))
corr <- correlate(mtcars, cor.test = TRUE)
cor_network(corr$r, corr$p.value)

## return a igraph object
cor_network(corr$r, corr$p.value, val.type = "igraph")

## reurn a tbl_graph object
cor_network(corr$r, corr$p.value, val.type = "tbl_graph")

houyunhuang/ggcor documentation built on July 22, 2020, 8:31 p.m.