I have a shiny app and my server function looks like this:
shinyServer(function(input, output, session) {
filedata <- reactive({
infile <- input$file1
if (is.null(infile)) {
return(NULL)
}
myDF <- fread(infile$datapath)
return(myDF)
# Return the requested graph
graphInput <- reactive({
switch(input$graph,
"Plot1" = plot1,
"Plot2" = plot2)
})
output$selected_graph <- renderPlot({
paste(input$graph)
})
output$plot1 <- renderPlot({
#fill in code to create a plot1
})
output$plot2 <- renderPlot({
#fill in code to create plot2
})
The UI function looks like this:
shinyUI(pageWithSidebar(
headerPanel("CSV Viewer"),
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')),
selectInput("graph", "Choose a graph to view:",
choices = c("Plot1", "Plot2"))
submitButton("Update View")
),#end of sidebar panel
mainPanel(
tabsetPanel(
tabPanel("Graph Viewer", plotOutput("selected_graph"))
)
I can't make the selected plot display on the screen. When I make a selection from the drop-down menu and click the "Update View" button the app does not display the plot. It does not display an error message. It displays nothing at all.
How can I fix this?