- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何让 renderUI 对从下拉列表中选择不同值的用户使用react,而无需单击我的提交按钮?
我有一个包含 3 件事的 wellPanel:
1) 我的下拉列表
2) 一组动态输入(由我的 renderUI 函数创建,取决于 #1 中的选择)
3) 提交按钮
期望的行为:对下拉选择的更改为用户提供了不同的输入小部件以供使用。当他们准备好选择输入的结果时,他们单击提交按钮,然后在主面板中获得结果。
问题:我的 renderUI 仅在单击提交按钮后对下拉选择使用react。据我所知,我需要隔离某些东西或使用observeEvent,但我无法弄清楚。
简化示例:
rm(list = ls())
library(shiny)
ui <- fluidPage(
fluidRow(
column(4,wellPanel(
selectInput("analysis", label = "Type of Analysis:",
c("Award Total" = "total",
"Award Average" = "average"),
width = validateCssUnit("70%")),
uiOutput("filter_box"),
submitButton()
)),
column(8, textOutput("sample_text"))
)
)
server <- function(input, output, session){
output$filter_box <- renderUI({
if(input$analysis == "total"){
tagList(radioButtons(inputId = "input1", label = "Select One:",c("A", "B", "C"), selected = "A"))
} else {
tagList(checkboxGroupInput(inputId = "input2", label = "Select all that apply:",c("1","2","3","4","5")),
dateRangeInput(inputId = "input3", label = "Enter Date Range"))
}
})
output$sample_text <- renderText({
if(input$analysis == "total"){
input$input1
} else if(input$analysis == "average") {
c(input$input2, input$input3)
}
})
}
runApp(list(ui = ui, server = server))
最佳答案
您需要引入两个更改。
submitButton
到 actionButton
(见@daattali 的评论)renderText
,并使其对 actionButton 产生 react 。 rm(list = ls())
library(shiny)
ui <- fluidPage(
fluidRow(
column(4,wellPanel(
selectInput("analysis", label = "Type of Analysis:",
c("Award Total" = "total",
"Award Average" = "average"),
width = validateCssUnit("70%")),
uiOutput("filter_box"),
actionButton(inputId = 'button_1',label = 'Apply Changes')
)),
column(8, textOutput("sample_text"))
)
)
server <- function(input, output, session){
output$filter_box <- renderUI({
if(input$analysis == "total"){
tagList(radioButtons(inputId = "input1", label = "Select One:",c("A", "B", "C"), selected = "A"))
} else {
tagList(checkboxGroupInput(inputId = "input2", label = "Select all that apply:",c("1","2","3","4","5")),
dateRangeInput(inputId = "input3", label = "Enter Date Range"))
}
})
output$sample_text <- renderText({
input$button_1
isolate({
if(input$analysis == "total"){
input$input1
} else if(input$analysis == "average") {
c(input$input2, input$input3)
}
})
})
}
runApp(list(ui = ui, server = server))
关于r - Shiny:使 renderUI 对下拉列表使用react,而不是 submitButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41404693/
在我 Shiny 的应用程序中,我有两个选项卡:选项卡 1 有一个 checkboxInput 和一个 selectInput,它在 server.R 中编码为 renderUI,并且仅在选中该框时显
我正在关注 this tutorial学习构建 Shiny 的应用程序。在最终版本中,“Country”的 renderUI() 仅采用数据集中的所有国家/地区。有没有办法根据使用 slider 选择
我正在为我 Shiny 的应用程序开发数据选择组件。 输入是一个 data.frame。 然后有一个动态数据选择 UI(由 renderUI() 实现)供用户按不同的列选择数据。 默认情况下,我希望数
我正在使用 renderUI 根据用户对可视化选项的选择来选择性地呈现表格或绘图。我还使用 Shiny 模块在多个选项卡上呈现相同的内容。虽然我已经让 Shiny 模块在另一个应用程序中工作得很好,但
对于我的许多 Shiny 应用程序来说,一个常见的情况是存在大量可能有趣的过滤器变量(通常是 10 到 20 个),但我想避免过多的输入小部件让用户感到困惑. 因此,我的策略通常如下:1.用户可以选择
我正在编写一个 Shiny 的应用程序来实现以下效果: 每当我选择 categoryname 包含的变量时,网络将生成提供分隔线的 slider 。它将所选变量分为 2 组,并形成一个新列,其中包含添
我在 Shiny App 中遇到了一个看似很小但很棘手的响应式(Reactive)函数问题。 该应用程序旨在在选择公司时显示折线图,并在选择“全部”时显示所有公司的条形图。例如在选择时: 按类别 1
我正在尝试使用 renderUI 和 uiOutput 通过 for 循环动态创建一些内容,但每个呈现的元素仅包含 for 循环中最后一次迭代的信息.示例: require(shiny) ui <-
我正在尝试在我的 ShinyApp 中使用 ShinyFiles 库,以便让用户可以选择一组文件或目录。 我的想法是使用根据复选框选择而变化的 uiOutput。 我在这里报告代码,这可能比文字更能说
我正在尝试模块化 Shiny 代码,以将 CSV 文件作为输入上传到 scatterD3 图中。额外的 UI 控件将从 renderUI 更改 x 变量和 y 变量。这只是来自 How to orga
我是 Shiny 的新手,我在 Shiny 方面遇到了问题。我有一个情节,但情节没有以 Shiny 的形式显示。并且没有消息错误。这是代码... 用户界面 library(shiny) ui = fl
如何在响应式包装器中使用从 renderUI 元素获取的值? 即我的代码: CompanyNames <- sqlQuery(connection, "SELECT Companynm FROM Ri
我在使用 R 中的 Shiny 包时遇到困难。 我试图理解为什么 server.R 中的“# Option 1”不起作用,但注释“# Option 2”却起作用。当“# Option 1”处于事件状态
我正在尝试在 Shiny 服务器上的应用程序中利用一些动态 GUI 事件。我的应用程序需要创建可变数量的 slider ,具体取决于输入到我的应用程序中的数据。具体来说,我正在尝试创 build 置一
我认为如何使用 Shiny 的 renderUI 功能动态子集数据的问题经常出现,但我很难理解何时使用 renderUI (带有 uiOutput)而不是其他功能,包括观察、 react 、 reac
我正在构建一个 Shiny 的应用程序,用于从数据库进行数据可视化。我正在尝试使用 renderUI 中的输入值运行 ggplot 但出现错误 Error in na.omit(xVariable)
我希望能够在我的 Shiny 应用程序中将动态矢量显示为文本输出。我还想利用 HTML(粗体、字体颜色等),所以我使用 htmlOutput 和 renderUI 而不是 textOutput 和 r
我正在尝试将一段代码转换为 Shiny 的模块,但我的 renderPlot()在 lapply() 中生成的函数似乎没有工作。我在下面创建了一个简单的示例来演示该问题。 (注意:这里我使用 rend
我正在尝试使用一个 react 模型,其中一个输入影响多个输出,如 Shiny 的备忘单中所述。 我需要使用 renderUI,因为选择列表是动态呈现的(示例中未显示) 但是,在初始化期间 selec
如何让 renderUI 对从下拉列表中选择不同值的用户使用react,而无需单击我的提交按钮? 我有一个包含 3 件事的 wellPanel: 1) 我的下拉列表 2) 一组动态输入(由我的 ren
我是一名优秀的程序员,十分优秀!