d3Networkライブラリのインストール
install.packages("d3Network")
server.R
library(d3Network) shinyServer(function(input, output) { output$networkPlot <- renderPrint({ #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) d3SimpleNetwork(NetworkData, height = 300, width = 700) }) })
ui.R
library(shiny) shinyUI(fluidPage( # Load d3.js tags$head( tags$script(src = 'http://d3js.org/d3.v3.min.js') ), # Application title titlePanel('d3Network Shiny Example'), p('This is an example of using', a(href = 'http://christophergandrud.github.io/d3Network/', 'd3Network'), 'with', a(href = 'http://shiny.rstudio.com/', 'Shiny', 'web apps.') ), # Sidebar with a slider input for node opacity sidebarLayout( sidebarPanel( sliderInput('slider', label = 'Choose node opacity', min = 0, max = 1, step = 0.01, value = 0.5 ) ), # Show network graph mainPanel( htmlOutput('networkPlot') ) ) ))
library(shiny) runApp("myApp")