Hi,
I pretty new on Shiny App. When I choose my data from an excel file, I would like to select the sheet and to show it on the App.
I use reactive to show and select on SelectInput the name of the datasheet but when I change the select sheet, it appears 1s and go back to the 1st sheet. What is wrong in my code?
Thank you
library(shiny)
library(readxl)
ui <- fluidPage(
fileInput('file1', 'Input'),
selectInput('sheet', 'Afficher sheet', ""),
tableOutput('table')
)
server <- function(input, output, session) {
data <- reactive({
req(input$file1) ## ?req # require that the input is available
inFile <- input$file1
updateSelectInput(session, inputId = 'sheet',
choices = excel_sheets(inFile$datapath)
)
my_data <- read_excel(inFile$datapath, sheet = input$sheet)
return (my_data)
})
output$table <- renderTable({
data()
})
}
shinyApp(ui, server)