jsonNodesLinks: Nodes and Links json

Description Usage Arguments Author(s) Examples

Description

Creates a json file with nodes and links. This json will work with D3Force

Usage

1
jsonNodesLinks(nodes, links)

Arguments

nodes

A dataframe containing the nodes. One of the columns should be labelled 'name'. The rest of the columns can be any node attribute.

links

A dataframe containing the links. This should consists of two columns: source and target. These should be populated with names that are in the names column of the nodes table. An optional weight column can also be included that will define the distance between nodes. weight should ideally between 0 and 1. If no column is provided it will default to 1

Author(s)

Simon Raper

Examples

1
2
3
4
5
nodes.df<-data.frame(name=c("Dan", "Digby", "Lex", "Flamer", "Stripey"), group=c(32, 38, 45, 17, 2))
links.df<-data.frame(source=c("Dan", "Digby", "Flamer"), target=c("Lex", "Flamer", "Stripey"))
link_weights.df<-data.frame(source=c("Dan", "Digby", "Flamer"), target=c("Lex", "Flamer", "Stripey"), weight=c(0.2, 0.3, 0.9))
jsonNodesLinks(nodes.df, links.df)
jsonNodesLinks(nodes.df, link_weights.df)

jamesthomson/R2D3 documentation built on May 18, 2019, 11:21 a.m.