
Last chance! 50% off unlimited learning
Sale ends in
d3SimpleNetwork
creates simple D3 JavaScript force directed network
graphs.
d3SimpleNetwork(Data, Source = NULL, Target = NULL, height = 600, width = 900, fontsize = 7, linkDistance = 50, charge = -200, linkColour = "#666", nodeColour = "#3182bd", nodeClickColour = "#E34A33", textColour = "#3182bd", opacity = 0.6, parentElement = "body", standAlone = TRUE, file = NULL, iframe = FALSE, d3Script = "http://d3js.org/d3.v3.min.js")
Source = NULL
then the first column of the data frame is
treated as the source.Target = NULL
then the second column of the data frame is
treated as the target.body
.file = NULL
then result is returned to the console.iframe = TRUE
then the graph is saved to an
external file in the working directory and an HTML iframe
linking to
the file is printed to the console. This is useful if you are using Slidify
and many other HTML slideshow framworks and want to include the graph in the
resulting page. If you set the knitr code chunk results='asis'
then
the graph will be rendered in the output. Usually, you can use
iframe = FALSE
if you are creating simple knitr Markdown or HTML
pages. Note: you do not
need to specify the file name if iframe = TRUE
, however if you do, do
not include the file path.# Fake data
Source <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
Target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
NetworkData <- data.frame(Source, Target)
# Create graph
d3SimpleNetwork(NetworkData, height = 300, width = 700,
fontsize = 15)
Run the code above in your browser using DataLab