sgraph

R package for sigma.js v2.4.0 graph visualization. Htmlwidgets wrapper inspired by the sigmaNet package.

Installation

Development version, using the remotes package in R:

  remotes::install_git('https://gitlab.com/thomaschln/sgraph.git')

Stable version from CRAN, in R:

  install.packages('sgraph')

Usage

Build a sgraph object from an igraph object

  library(igraph)
  library(sgraph)
 
  data(lesMis)
 
  sig <- sigma_from_igraph(lesMis)
  sig

Modify the node size of a sgraph object.

 
  # one size for all nodes
  sig %>% add_node_size(one_size = 7)
 
  # using a vector
  df_nodes = cbind.data.frame(name = vertex_attr(lesMis, 'id'),
    degree = degree(lesMis))

  # seems sigma.js is not scaling automatically with min_size and max_size
  # do it manually for now
  df_nodes$degree %<>% scale(center = FALSE) %>% `*`(3) %>% `+`(3)

  igraph = add_igraph_info(lesMis, df_nodes)

  sig <- sigma_from_igraph(lesMis) %>%
   add_node_size(size_vector = vertex_attr(igraph, 'degree'), min_size = 3, max_size = 8)
  sig

Modify the node labels of a sgraph object.

  sig %>%
    add_node_labels(label_attr = 'label')

Use in Shiny and Flexdashboard (see examples in shiny-server folder)

Development status

Submitted to CRAN

License

This package is free and open source software, licensed under GPL-3.