小编Anu*_*wal的帖子

在 Shiny 服务器启动时触发用于 selectInput 的 Shiny R observeEvent

下面是一个示例 Shiny 应用程序:

用户界面

shinyUI(fluidPage(

  # Application title
  titlePanel("Test select input event"),
  sidebarLayout(
    sidebarPanel(
      selectInput('testSelect', 'Test',choices = c(1,2,3), multiple = FALSE)
    ),
    mainPanel(
    )
  )
))
Run Code Online (Sandbox Code Playgroud)

服务器.R

shinyServer(function(input, output) {

  observeEvent(input$testSelect,{ print("I am getting trigerred unnecessarily")})

})
Run Code Online (Sandbox Code Playgroud)

当我启动这个应用程序时,控制台日志立即显示:

http://127.0.0.1:5017
[1] “我不必要地被触发”

似乎observeEvent在应用程序开始时不必要地触发了选择输入。有人可以解释这种行为吗?

r shiny

3
推荐指数
1
解决办法
4609
查看次数

标签 统计

r ×1

shiny ×1