tab4net: Prepare inputs for sankeyNetwork()

View source: R/tab4net.R

tab4netR Documentation

Prepare inputs for sankeyNetwork()

Description

This function generates lists from column-oriented tables (data frames) for Sankey Networks diagrams produced by networkD3::sankeyNetwork().

Usage

tab4net(formula, data, FUN, ...)

Arguments

formula

A formula passed to stats::aggregate(). On the right side the factors are sorted from the first source to the last target.

data

A data frame with the variables included in 'formula'.

FUN

A function passed to stats::aggregate().

...

Further arguments passed to stats::aggregate().

Value

A list with two data frames called 'nodes' and 'links'.

Examples

require(networkD3)

## Different values of WET-Health scores for vegetation per land use
veg_wh <- tab4net(UseunitID ~ Landuse + WET_veg, WHscores, length)

sankeyNetwork(
  Links = veg_wh$links, Nodes = veg_wh$nodes, Source = "source",
  Target = "target", Value = "value", NodeID = "name",
  units = "TWh", fontSize = 12, nodeWidth = 30
)


kamapu/Lexiguel documentation built on July 29, 2022, 7:52 p.m.