r - Shiny - 通过 updateSelectInput() 在 selectInput() 中更改“选择”
问题描述
我正在尝试根据第一个 selectInput() 中的选择更改第二个 selectInput() 中的选择。这是我的代表。提前感谢您的帮助。
library(shiny)
ui <- fluidPage(
tabPanel("tbls",
selectInput("tab1",label="Pick a table:",choices=c("a","b","c")),
selectInput("cht1",label="Pick a time series:",choices=c("d","e","f"))
)
)
server <- function(input,output,session) {
Nchoices <- reactive({case_when(
input$tab1=="a" ~c("d","e","f"),
input$tab1=="b" ~c("g","h","i"),
input$tab1=="c" ~c("j","k","l")
)})
observeEvent(input$tab1,{updateSelectInput(session,input$cht1,
label="Pick a time series:",choices=Nchoices(),selected=NULL)})
observe(print(Nchoices()))
}
shinyApp(ui, server)
解决方案
推荐阅读
- nginx - Camunda Webapp 的 Nginx 配置
- ruby-on-rails - 我可以在旅途中将属性附加到 Ruby OpenStruct 吗?
- c# - 添加文本框时的 C# WinForms 上下文菜单焦点问题
- javascript - 无法解决 500(内部服务器错误)代码
- c++ - 如何对 const char* 向量的向量进行排序
- php - 为按 ID 获取元素创建一个函数
- dynamic - D* / D* Lite 查询(动态寻路算法)
- javascript - javascript 等效于 jquery 最接近().find()
- excel - 基于两个条件(包括范围字段之间)的查找
- excel - 使用条件语句导出表单过滤器数据