as_igraph: Convert ICON objects to igraph objects

Description Usage Arguments Details Value Examples

View source: R/converters.R

Description

'ICON::get_data' returns data frames that also have class 'ICON'. However, conducting network analysis could require using another R package and its associated network structure and class. The 'as_igraph' function converts 'ICON' objects to 'igraph' objects. It allows 'ICON' users to take full advantage of the functionality provided in the 'igraph' package.

Usage

1
as_igraph(x, directed = FALSE, weighted = (ncol(x) > 2))

Arguments

x

edgelist of classes 'ICON' and 'data.frame' to be coerced

directed

'TRUE' if network has directed edges; 'FALSE' otherwise

weighted

'TRUE' if network has weighted edges; 'FALSE' otherwise

Details

Note that if the 'ICON' object has more than two columns, 'as_igraph' assumes that the third column is numeric and represents edge weights. Use 'weighted = FALSE' to ignore existing edge weights and re-order columns if you would prefer another column be used for edge weights.

Value

an 'igraph' object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# download dataset using ICON
get_data("chess")

# don't care about relabeled vertices
converted <- as_igraph(chess, directed = TRUE, weighted = TRUE)

# look at edges
igraph::E(converted)

# look at edge weights
igraph::E(converted)$weight

## End(Not run)

rrrlw/ICON documentation built on May 16, 2021, 8:40 a.m.