r - 如何在另一个 ui pickerInput 选项中使用数字输入?
问题描述
在闪亮中,我需要选择一个数字范围并将其用作另一个选择器输入中的选择。
首先我有:
sliderTextInput(
inputId = "size.range",
label = "Choose a value:",
choices = c(1:100),
selected =c(18,24),
grid = TRUE )
在我拥有之后:
pickerInput(
inputId = "sample.histoall",
label = "Selected Size",
choices = list( XXXXXX ),
options = list(`actions-box` = TRUE),
multiple = TRUE)
我用什么替换 XXXXXX ?
解决方案
您可以观察数值范围的值并pickerInput
在每次更改时更新您的值。您可以选择在您的pickerInput
. 我在下面的示例中添加了这两个选项。
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
sliderTextInput(
inputId = "size.range",
label = "Choose a value:",
choices = c(1:100),
selected =c(18,24),
grid = TRUE ),
pickerInput(
inputId = "sample.histoall",
label = "Selected Size",
choices = list( '' ),
options = list(`actions-box` = TRUE),
multiple = TRUE),
pickerInput(
inputId = "sample.histoall.range",
label = "Selected Size",
choices = list( '' ),
options = list(`actions-box` = TRUE),
multiple = TRUE)
)
server <- function(input, output, session) {
observe({
updatePickerInput(session, 'sample.histoall', choices=input$size.range)
updatePickerInput(session, 'sample.histoall.range', choices=as.numeric(input$size.range[1]):as.numeric(input$size.range[2]))
})
}
shinyApp(ui, server)
推荐阅读
- mysql - 找不到包 libmysqlclient-dev
- java - JWT 是否应该是一个单独的身份验证微服务,而不是与后端业务逻辑坐在一起?
- javascript - 如何在 react-bootstrap 中更改我的 5 个选项卡之一的颜色?
- node.js - find 和 findone 给我模型内容而不是记录
- c# - 从 .NET Core 将 JSON 文件批量上传/导入到 Azure Cosmos DB
- rust - 如何在一行中从算术创建字符串切片?
- python - Python elif not working as expected for string find
- mysql - 谷歌云控制台(Appengine)中的Mysql实例崩溃
- php - 没有从 ajax 获取 POST 值
- json - 删除数据并导航到同一页面