Converts Table to 'd3' Nodes and Links

d3_table(tB = NULL, vars = NULL, agg = "Freq")

Arguments

tB

table to convert

vars

character vector of column names

agg

character column name of aggregated value

Value

list of two data.frames - one for nodes and one for links of the network. This structure is helpful when working with networkD3 and visNetwork.

Examples

library(d3r) d3_table(Titanic, c("Class","Sex"))
#> $nodes #> name value #> 1 1st 325 #> 2 2nd 285 #> 3 3rd 706 #> 4 Crew 885 #> 5 Male 1731 #> 6 Female 470 #> 7 Titanic 2201 #> #> $links #> source target value #> 1 0 4 180 #> 2 1 4 179 #> 3 2 4 510 #> 4 3 4 862 #> 5 0 5 145 #> 6 1 5 106 #> 7 2 5 196 #> 8 3 5 23 #> 9 6 0 325 #> 10 6 1 285 #> 11 6 2 706 #> 12 6 3 885 #>