Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to "reset" a fileInput widget and the underlying data (must treat these as two different things)
library(shiny)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
fileInput('inFile', 'Choose file'),
actionButton('reset', 'Reset'),
tableOutput('tbl')
)
server <- function(input, output, session) {
rv <- reactiveValues(data = NULL)
observe({
req(input$inFile)
rv$data <- read.csv(input$inFile$datapath)
})
observeEvent(input$reset, {
rv$data <- NULL
reset('inFile')
})
output$tbl <- renderTable({
rv$data
})
}
shinyApp(ui, server)
@fawda123

This comment has been minimized.

Copy link

@fawda123 fawda123 commented Apr 14, 2017

Thanks this is helpful, but is there any way to print the table if the data are uploaded again after reset?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment