InsertUI不捕获和显示selectInput的输入

时间:2018-06-13 01:11:32

标签: shiny

为什么捕获并显示的反应值是反$ $ counterValue?如何捕获和显示其他反应值?我希望能够捕捉到两者;用户按下按钮的次数,并调用insertInput()和用户在每个显示的insertInput()中选择的文件数。谢谢。

library(shiny)

ui <- fluidPage(
  actionButton("add", "Add UI"),
  textOutput("count")
)

server <- function(input, output, session) {
  counter <- reactiveValues(countervalue = 0)
  counter2 <- reactiveValues(countervalue2 = 0)
  numberOfItems <- reactiveValues(selections = NULL)
  observeEvent(input$add,{
    isolate({
      counter$countervalue <- counter$countervalue + 1 

    })

    isolate({
      numberOfItems$selections <- unlist(input$filescombine)

    })

    isolate({
      counter2$countervalue2<- counter$countervalue2 + 1
    })
    insertUI(

        selectInput("filescombine",label = h5(strong("PLEASE CHOSE FILES TO COMBINE. To undo selection select the selected file again and press delete")),c(Choose='', list.files("~/Development/fileTest/GLYCOUNT/DATA")), multiple=TRUE, selectize=TRUE),
        selector = "#add",
        where = "afterEnd",
        numberOfItems$selections <- input$filescombine
      )

    })
    output$count <- renderText({
    paste(counter$countervalue, counter2$countervalue2, numberOfItems$selections)# print the latest value stored in the reactiveValues object
    })

  }

  shinyApp(ui, server)

0 个答案:

没有答案