2016-03-18 179 views
0

我從閃亮的用戶界面有這個代碼。UI相關的閃亮輸入R

我想要一個輸入依賴於UI中的其他輸入。因此可以說,如果用戶在一個輸入中插入100,我希望另一個輸入的MIN例如輸入$ 1 * 5。所以在這種情況下,輸入數字2的最小值將爲500.

我附加了我想要工作的代碼,但它沒有。是否有任何其他解決方法可以考慮?

感謝

ui <- fluidPage(
    (titlePanel("Price estimation", windowTitle = "app")), 

    sidebarLayout(sidebarPanel(

    checkboxGroupInput(inputId = "checkgroupuno", 
         label = "Select stages", 
         choices = c("Proekt","Working Design", 
            "Tender Design", "Concept"), 
         selected = "Proekt", inline = F), 

    radioButtons(inputId = "radiouno", 
         label = "Select Design", 
         choices = c("Shell & Core","Fit Out", 
            "Shell Core & Fit Out"), 
         selected = "Shell & Core", inline = F), 

    sliderInput(inputId = "slideruno", 
       label = "Size", min = 0, max = 250000, value = 50000,ticks = T), 

    sliderInput(inputId = "sliderdos", 
       label = "TIME", min = input$slideruno * 10, max = input$slideruno * 15, value = input$slideruno * 10,ticks = T) 



), 

    mainPanel(plotlyOutput(outputId = "plotuno")) 
)) 

回答

1

您可以動態創建滑塊,像這樣:

rm(list = ls()) 
library(shiny) 
library(plotly) 
ui <- fluidPage(titlePanel("Price estimation", windowTitle = "app"), 

    sidebarLayout(sidebarPanel(
    checkboxGroupInput(inputId = "checkgroupuno",label = "Select stages", 
         choices = c("Proekt","Working Design","Tender Design", "Concept"),selected = "Proekt", inline = F), 

    radioButtons(inputId = "radiouno",label = "Select Design",choices = c("Shell & Core","Fit Out","Shell Core & Fit Out"),selected = "Shell & Core", inline = F), 
    sliderInput(inputId = "slideruno",label = "Size", min = 0, max = 250000, value = 50000,ticks = T), 
    uiOutput("custom_sliderdos")  
) 

    ,mainPanel(plotlyOutput(outputId = "plotuno")) 
)) 

server <- function(input, output) { 
    output$custom_sliderdos <- renderUI({sliderInput(inputId = "sliderdos", label = "TIME", min = input$slideruno * 10, max = input$slideruno * 15, value = input$slideruno * 10,ticks = T)}) 
} 
shinyApp(ui, server) 

enter image description here