在R闪亮中使用outputOptions时出错

SNT*_*SNT 7 r r-markdown shiny shiny-reactivity

我在一个应用程序中有一个选择框,我试图使用outputOptions它,以便它将使用生成我的报告中的所有选项卡.以下是代码:

observeEvent(input$tab, {
  if (input$tab == "fruits"){
    choices <- c(
      "Apples",
      "Oranges"
    )
  }
  else if (input$tab == "vegetables") {
    choices <- c(
      "potatoes",
      "squash"
    )
  }

  else {
    choices <- c(
      "berries",
      "onions"
    )
  }
  updatePickerInput(session,
                    inputId = "selected_metric",
                    choices = choices)
})

outputOptions(output, "selected_metric", suspendWhenHidden = FALSE)
Run Code Online (Sandbox Code Playgroud)

以下是我得到的错误

.subset2(x,"impl")中的错误$ outputOptions(name,...):selected_metric不在输出对象列表中