I'm just getting started with Shiny, but I have been using googleVis within R for some time now, and I have successfully produced Sankey Diagrams prior. I'm setting up a Shiny app to allow for filtering on specific values in order to generate a more interactive Sankey diagram; however, I cannot render a diagram regardless of whether I am using reactive variables or the data without any reactive components.
I am not receiving any error while using the non-reactive data, just no rendering. My code for both server.R and ui.R are below:
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"))
)
))
I can't readily see any major conflicts that could be causing my Sankey diagram not to render within the app. I've seen several posts on other forums where people have successfully done this, but with no instruction or example code.