我有一个有两个numericInput()
的闪亮应用程序。一个代表最小值,第二个代表最大值。是否可以将最小值的最大值设置为最大值?
library(shiny)
ui <- fluidPage(
uiOutput("filter")
)
server <- function(input, output) {
output$filter<-renderUI({
"range"=tagList(
numericInput("obs", "Min:", 10, min = 1, max = 100),
numericInput("obs2", "Max:", 10, min = 1, max = 100)
)
})
}
shinyApp(ui, server)
您可以使用renderUI()
:
library(shiny)
ui <- fluidPage(
uiOutput("obs1"),
numericInput("obs2", "Max:", 10, min = 1, max = 100),
verbatimTextOutput("value")
)
server <- function(input, output) {
output$value <- renderText({
input$obs
})
output$obs1 <- renderUI({
val <- min(input$obs, as.numeric(input$obs2))
numericInput("obs", "Min:", val, min = 1, max = as.numeric(input$obs2))
})
}
shinyApp(ui, server)