Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 动态更改下一个输入的数据_R_Shiny - Fatal编程技术网

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{..}