`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.

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

Value

an `igraph` object

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.

Examples

if (FALSE) { # 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 }