GVis Sankey Diagram与Shiny:Rendering Issue的集成

时间:2016-06-22 14:51:39

标签: r google-visualization shiny sankey-diagram

我刚刚开始使用Shiny,但我已经在R中使用了googleVis一段时间了,之前我已经成功制作了Sankey Diagrams。我正在设置一个Shiny应用程序以允许对特定值进行过滤,以生成更具交互性的Sankey图表;但是,无论我是使用反应变量还是没有任何无功组件的数据,我都无法渲染图表。

我在使用非反应数据时没有收到任何错误,只是没有渲染。我的server.R和ui.R的代码如下:

server.R

 library(shiny)
library(googleVis)

## establish connection to data file/database
dat <- as.data.frame(read.csv('types_yearToOrderToAuthor.csv', header=TRUE, sep=','))

# Define server logic required to draw a Sankey Diagram
shinyServer(function(input, output) {

  ## describe sankey for user
  output$desc <- renderText(input$taxon)
  output$range <- renderText(input$range)

  ## query/filter data file based on input parameters
  selectedData <- reactive({dat[, dat$destination == input$taxon]})

  ## create and output googleVis Sankey Flow Diagram to user
  output$plot <-  renderGvis({gvisSankey(as.data.frame(dat), from="source", to="destination", weight="weight")})

})

ui.R

library(shiny)

shinyUI(fluidPage(
  titlePanel("ANSP Entomology Type Sankey Visualization Test"),
  sidebarLayout(
    sidebarPanel(
      helpText("Explore temporal trends within the ANSP 
               Entomology Department Type Collection."),
      sliderInput("range", 
                  label = h3("Year(s) of interest:"),
                  min = 1800, max = 2016, value = c(0, 20), sep = ""),
      checkboxGroupInput("taxon", label = h3("Order(s) of interest:"), 
                         choices = list("Coleoptera" = 'Coleoptera', 
                                        "Diptera" = 'Diptera', "Hemiptera" = 'Hemiptera',
                                        "Hymenoptera" = 'Hymenoptera', "Lepidoptera" = 'Lepidoptera',
                                        "Orthoptera" = 'Orthoptera', "Minor Orders" = ''),
                         selected = "Orthoptera"),
      hr(),
      fluidRow(helpText("Viewing the order(s): "),
               verbatimTextOutput("desc"), helpText( "under the date range of: "),
               verbatimTextOutput("range"))
      ),
      mainPanel(htmlOutput("plot"))
  )
))

我无法轻易看到任何可能导致我的Sankey图表无法在应用内呈现的重大冲突。我在其他论坛上看过几篇人们已成功完成此任务的帖子,但没有说明或示例代码。

0 个答案:

没有答案