I am using this code, and keep running into a Error in updateSelectInput: object 'session' not found. This happens when I try to upload any file, through the fileInput option. When I remove the updateSelectInput statement, the table prints fine. (Note that Im providing the bare minimum code necessary to reproduce the problem, the code doesnt include portions where I expect to use the SelectInput inputs).
library(shiny); library(shinythemes); library(DT)
ui<- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput(inputId = "default_csv",label="input the file"),
selectInput(inputId = "facility_id1", label="Choose the facilityID column", choices ="FacilityID"),
numericInput(inputId = "obs", label="Choose number of obs", value=10)
),
mainPanel(
dataTableOutput(outputId = "table")
)
)
)
server<- function(input, output){
data_set <- reactive({
data_set<-read.csv(input$default_csv$datapath, stringsAsFactors = FALSE)
})
observe({
req(input$default_csv)
dsnames <- names(data_set())
updateSelectInput(session, "facility_id1", label = "Facility ID",
choices = dsnames, selected = "")
cat("update done")
})
output$table<- renderDataTable(head(data_set(),n=input$obs))
}
shinyApp(ui=ui, server=server)
Warning: Error in updateSelectInput: object 'session' not found
Stack trace (innermost first):
57: updateSelectInput
56: observerFunc [C:/Users//Desktop/9.R#29]
1: runApp
ERROR: [on_request_read] connection reset by peer
The server function is missing the session
argument:
server <- function(input, output, session)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With