gpt4 book ai didi

r - updateSelectinput 抛出 session 未找到错误

转载 作者:行者123 更新时间:2023-12-02 01:44:28 25 4
gpt4 key购买 nike

我正在使用此代码,但在 updateSelectInput 中不断遇到错误:找不到对象“ session ”。当我尝试通过 fileInput 选项上传任何文件时,会发生这种情况。当我删除 updateSelectInput 语句时,该表打印正常。 (请注意,我提供了重现问题所需的最低限度代码,该代码不包括我希望使用 SelectInput 输入的部分)。

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

最佳答案

服务器函数缺少session参数:

server <- function(input, output, session)

关于r - updateSelectinput 抛出 session 未找到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46749013/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com