R 动态更改下一个输入的数据
我的数据库中有两个选择输入 用户界面 有光泽的图书馆R 动态更改下一个输入的数据,r,shiny,R,Shiny,我的数据库中有两个选择输入 用户界面 有光泽的图书馆 ContextElements = c("choice1", "choice2", "choice3") shinyUI(pageWithSidebar( headerPanel(""), sidebarPanel( h4("test for selectize input"), selectizeInput(inputId = "firstAxe", label = h4("First Axe"),
ContextElements = c("choice1", "choice2", "choice3")
shinyUI(pageWithSidebar(
headerPanel(""),
sidebarPanel(
h4("test for selectize input"),
selectizeInput(inputId = "firstAxe", label = h4("First Axe"),
choices=ContextElements, selected = NULL, multiple = FALSE,
options = NULL),
hr(),
selectizeInput(inputId = "twoAxe", label = h4("Second Axe"),
choices=NULL, selected = NULL, multiple = FALSE,
options = NULL)
),
mainPanel(
)
))
我希望下一个selectizeinput选项twoAxe动态填充第一个选项的剩余选项,这意味着如果我选择了第一个选项,那么第二个选项将是choice2和choice3
谢谢您可以在server.r中使用updateSelectizeInput执行此操作。让我们假设ContextElements对服务器可用-在global.r中定义,或者在server.r和ui.r中都定义。那么这应该是可行的:
observe({
input$firstAxe # makes the second selectize change when the first one does
updateSelectizeInput({session, inputId="twoAxe",
choices=as.list( ContextElements[!ContextElements %in% input$firstAxe] ) })
})
当您在firstAxe中更改选择时,您应该会看到twoAxe Response中的选择。如果没有完整的代码可供使用,我可以想象您可以在服务器.R端执行此操作,使用某种反应,其中包含一些影响ContextElements\u new的内容,它应该是updateSelectizeInput。。而不是updateSelectizeInput{..}