I'm putting together a shiny app and trying something along the lines of the following:
require("shiny")
ui <- fluidPage(
fluidRow(fileInput(inputId = "dataFile", label = NULL)),
fluidRow(wellPanel(tableOutput(outputId = "rawText")))
)
server <- function(input, output) {
observe({
upFile <- input$dataFile
if(!is.null(upFile)) {
raw.dat <<- reactive({
read.csv(file = upFile$datapath, header = TRUE, stringsAsFactors = FALSE)
})
} else raw.dat <<- reactive({})
})
output$rawFile <- renderTable(as.data.frame(raw.dat()))
}
shinyApp(ui = ui, server = server)
and yet even after I upload a file, raw.dat()
always, always returns NULL.
What am I missing?