D3Force: D3 Force

Description Usage Arguments Author(s) References Examples

View source: R/D3.R

Description

Creates a html file containing json file and a D3.js Force Directed Layout. If you want colours in the force directed layout to represent a group, please ensure the column is labelled "group" in the data frame

Usage

1
2
D3Force(JSON, file_out, arrows = FALSE, collision.detect = FALSE,
  fisheye = FALSE)

Arguments

JSON

A json object

file_out

the location and name for the output html file

arrows

Boolean do you want arrow heads. By default FALSE

collision.detect

Boolean do you want avoid collisions between nodes. By default FALSE

fisheye

Boolean do you want fish eye zooming. By default FALSE

Author(s)

Simon Raper and James Thomson

References

Mike Bostock's lovely d3: http://d3js.org/

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
nodes.df<-data.frame(name=c("Dan", "Digby", "Lex", "Flamer", "Stripey"), age=c(32, 38, 45, 17, 2))
links.df<-data.frame(source=c("Dan", "Digby", "Flamer"), target=c("Lex", "Flamer", "Stripey"))
JSON<-jsonNodesLinks(nodes.df, links.df)
D3Force(JSON, file_out="Force.html")

#With directional arrows
D3Force(JSON, file_out="Force.html", arrows=TRUE))

data(celebs)
colnames(celebs$relationships)<-c('source', 'target')
colnames(celebs$celebs)<-c('name', 'group')
JSON<-jsonNodesLinks(celebs$celebs, celebs$relationships)
D3Force(JSON, file_out="/Users/home/Documents/R_Projects/Force.html")

jamesthomson/R2D3 documentation built on May 17, 2017, 9:43 a.m.