2014-06-23 30 views
1

我想用两个numericInputs(一个& b)创建一个输入面板。 numericInput b的最大值需要来自numericInput a的值。

--- 
title: "test input" 
runtime: shiny 
output: html_document 
--- 

```{r, echo = FALSE} 
inputPanel(
    numericInput("a", "A", 80, 
       min = 1, max = 100), 

    numericInput("b", "B", 15, 
       min = 1, max = input$a) 
) 
``` 

这给了错误:

Operation not allowed without an active reactive context.

回答

1

嗨,你可以像在一个典型的闪亮应用:

```{r, echo = FALSE} 
shinyApp(

    ui = fluidPage(
    inputPanel(
     numericInput("a", "A", 80, 
       min = 1, max = 100), 
     uiOutput("numericInput_reactive") 
    ) 
), 

    server = function(input, output) { 
    output$numericInput_reactive <- renderUI({ 
     numericInput("b", "B", 15, 
       min = 1, max = input$a) 
    }) 
    } 
) 
``` 
3

不使用shinyApp的:

```{r, echo=FALSE} 
    inputPanel(
    numericInput("a", label="A", min = 1, max = 100, value = 80), 
    uiOutput('a') 
) 

    output$a <- renderUI({ 
    numericInput("b", label= "B", min = 1, max = input$a, value = 15) 
} 
) 
```