Learn R Programming

sgraph (version 1.1.0)

add_igraph_info: Add nodes information to the igraph object

Description

Modify the node attributes of an existing igraph object by providing a dataframe

Usage

add_igraph_info(igraph, df_nodes, fields = names(df_nodes))

Value

A sgraph object with modified node labels

Arguments

igraph

Igraph object to modify

df_nodes

Data frame to add to nodes

fields

Columns of df_nodes to add. First must be the node identifier.

Examples

Run this code
library(igraph)
library(sgraph)
data(lesMis)

df_nodes = cbind.data.frame(name = igraph::vertex_attr(lesMis, 'label'),
  log10_degree = degree(lesMis))

igraph = add_igraph_info(lesMis, df_nodes)

sig <- sigma_from_igraph(lesMis) %>%
  add_node_size(size_vector = 'log10_degree')

Run the code above in your browser using DataLab