在一个闪亮的应用程序(由RStudio),在服务器端,我有一个反应,通过解析a的内容返回变量列表textInput.然后在selectInput和/或中使用变量列表updateSelectInput.
我不能让它发挥作用.有什么建议?
我做了两次尝试.第一种方法是outVar直接使用反应selectInput.第二种方法是使用反应性outVar在updateSelectInput.两者都不起作用.
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) 我遇到了一个问题因为在加载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)