相关疑难解决方法(0)

R闪亮传递反应到selectInput选择

在一个闪亮的应用程序(由RStudio),在服务器端,我有一个反应,通过解析a的内容返回变量列表textInput.然后在selectInput和/或中使用变量列表updateSelectInput.

我不能让它发挥作用.有什么建议?

我做了两次尝试.第一种方法是outVar直接使用反应selectInput.第二种方法是使用反应性outVarupdateSelectInput.两者都不起作用.

server.R

shinyServer(
  function(input, output, session) {

    outVar <- reactive({
        vars <- all.vars(parse(text=input$inBody))
        vars <- as.list(vars)
        return(vars)
    })

    output$inBody <- renderUI({
        textInput(inputId = "inBody", label = h4("Enter a function:"), value = "a+b+c")
    })

    output$inVar <- renderUI({  ## works but the choices are non-reactive
        selectInput(inputId = "inVar", label = h4("Select variables:"), choices =  list("a","b"))
    })

    observe({  ## doesn't work
        choices <- outVar()
        updateSelectInput(session …
Run Code Online (Sandbox Code Playgroud)

r shiny shiny-reactivity

59
推荐指数
1
解决办法
6万
查看次数

R shiny观察运行在加载UI之前,这会导致Null参数

我遇到了一个问题因为在加载UI之前首先调用了observe.

这是我的ui.R

  sidebarPanel(
    selectInput("Desk", "Desk:" ,  as.matrix(getDesksUI())),
    uiOutput("choose_Product"), #this is dynamically created UI
    uiOutput("choose_File1"), #this is dynamically created UI
    uiOutput("choose_Term1"), #this is dynamically created UI  ....
Run Code Online (Sandbox Code Playgroud)

这是我的Server.R

shinyServer(function(input, output,session) {

  #this is dynamic UI
  output$choose_Product <- renderUI({ 
    selectInput("Product", "Product:", as.list(getProductUI(input$Desk)))
  })

   #this is dynamic UI
  output$choose_File1 <- renderUI({
    selectInput("File1", "File 1:", as.list(getFileUI(input$Desk, input$Product)))
  })

  #this is dynamic UI and I want it to run before the Observe function so the call
  # to getTerm1UI(input$Desk, input$Product, input$File1) has non-null parameters
  output$choose_Term1 …
Run Code Online (Sandbox Code Playgroud)

r shiny

14
推荐指数
3
解决办法
1万
查看次数

标签 统计

r ×2

shiny ×2

shiny-reactivity ×1