GithubHelp home page GithubHelp logo

ellisp / networkd3 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from christophergandrud/networkd3

0.0 2.0 0.0 1.1 MB

D3 JavaScript Network Graphs from R

Home Page: http://christophergandrud.github.io/networkD3

R 58.97% JavaScript 41.03%

networkd3's Introduction

D3 JavaScript Network Graphs from R

Version 0.1.8 Build Status CRAN Downloads

This is a port of Christopher Gandrud's d3Network package to the htmlwidgets framework.

This README includes information on set up and a number of basic examples. For more information see the package's main page.

Usage

Here's an example of simpleNetwork:

# Create fake data
src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
networkData <- data.frame(src, target)

# Plot
simpleNetwork(networkData)

Here's forceNetwork:

# Load data
data(MisLinks)
data(MisNodes)

# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 0.4,
             colourScale = "d3.scale.category20b()")

Here's sankeyNetwork using a downloaded JSON data file:

# Load energy projection data
library(RCurl)
URL <- "https://raw.githubusercontent.com/christophergandrud/networkD3/master/JSONdata/energy.json"
Energy <- getURL(URL, ssl.verifypeer = FALSE)

# Convert to data frame
EngLinks <- JSONtoDF(jsonStr = Energy, array = "links")
EngNodes <- JSONtoDF(jsonStr = Energy, array = "nodes")

# Plot
sankeyNetwork(Links = EngLinks, Nodes = EngNodes, Source = "source",
            Target = "target", Value = "value", NodeID = "name",
            fontSize = 12, nodeWidth = 30)

Saving to an external file

Use saveNetwork to save a network to stand alone HTML file:

library(magrittr)

simpleNetwork(networkData) %>% saveNetwork(file = 'Net1.html')

networkd3's People

Contributors

jjallaire avatar christophergandrud avatar timelyportfolio avatar bwlewis avatar ellisp avatar csese avatar kevinykuo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.