Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.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中reactiveValuesToList()函数的奇怪行为_R_Shiny_Reactive Programming - Fatal编程技术网

R中reactiveValuesToList()函数的奇怪行为

R中reactiveValuesToList()函数的奇怪行为,r,shiny,reactive-programming,R,Shiny,Reactive Programming,我最近发现了reactiveValuesToList()函数,我用它跟踪应用程序中的输入,因为有些输入是动态创建的。下面是一个简单的例子来说明函数的奇怪行为 我的应用程序有3个组件: checkBoxGroupInput():有3个选项 uiOutput():根据用户选中的框动态创建数字输入 textOutput():显示web应用程序中所有输入UI的ID 以下是上述简单应用程序的脚本: library(shiny) ui <- fluidPage( # The user se

我最近发现了
reactiveValuesToList()
函数,我用它跟踪应用程序中的输入,因为有些输入是动态创建的。下面是一个简单的例子来说明函数的奇怪行为

我的应用程序有3个组件:

  • checkBoxGroupInput()
    :有3个选项

  • uiOutput()
    :根据用户选中的框动态创建数字输入

  • textOutput()
    :显示web应用程序中所有输入UI的ID

以下是上述简单应用程序的脚本:

library(shiny)

ui <- fluidPage(

  # The user selects team names
  checkboxGroupInput(inputId = "team", label = "Select team", choices = letters[1:3]),

  br(),

  # Placeholder for the dynamic numeric inputs that are created based on the selected team names
  uiOutput(outputId = "dynUI1"),

  # Text output for the names of the input UIs in the shiny app
  textOutput(outputId = "uiIds")  
)

server <- function(input, output){

  # These are the input IDs of the dynamically created UI in dynUI1
  uiNames <- c(a = "id_a", b = "id_b", c = "id_c")

  output$dynUI1 <- renderUI({
    if(length(input$team) == 0){
      return(NULL)
    } else {
      lapply(1:length(input$team), function(i){
        inputname <- paste0("Points: team ", input$team[i])
        numericInput(inputId = uiNames[input$team[i]], label = inputname, value = 1, min = 1, max = 5)
      })
    }
  })

  output$uiIds <- renderText({
    names(reactiveValuesToList(input))
  }) 
}
shinyApp(ui = ui, server = server)
库(闪亮)

ui您是否尝试过使用闪亮0.14中的
insertUI
removeUI
来创建动态ui?如果是的话,这能解决问题吗?@warmoverflow,我没有。我会尝试一下,让你知道。谢谢。您是否尝试过使用闪亮0.14中的
insertUI
removeUI
来创建动态UI?如果是的话,这能解决问题吗?@warmoverflow,我没有。我会尝试一下,让你知道。非常感谢。