相关疑难解决方法(0)

如何在Shiny eventReactive处理程序中侦听多个事件表达式

我想要两个不同的事件来触发我的应用程序中各种图表/输出所使用的数据的更新.一个是单击按钮(input$spec_button),另一个是点击点上的点(mainplot.click$click).

基本上,我想同时列出两者,但我不知道如何编写代码.这就是我现在拥有的:

在server.R中:

data <- eventReactive({mainplot.click$click | input$spec_button}, {
    if(input$spec_button){
      # get data relevant to the button
    } else {
      # get data relevant to the point clicked
    }
  })
Run Code Online (Sandbox Code Playgroud)

但if-else子句不起作用

Error in mainplot.click$click | input$spec_button : operations are possible only for numeric, logical or complex types

- >我可以使用某种动作组合器功能用于该mainplot.click$click | input$spec_button子句吗?

r shiny

74
推荐指数
5
解决办法
3万
查看次数

重置 R 闪亮的 actionButton 以多次使用它

有人知道如何将 actionButton (R Shiny) 重置为初始值以便多次使用它吗?

请在下面找到一个可复制的示例

在这个例子中,我想通过选择相应的按钮来更改图表颜色:我的问题是它无法在一次迭代后重新加载图表。

library(shiny)

ui <- fluidPage(

  actionButton(inputId = "button1",label = "Select red"),
  actionButton(inputId = "button2",label = "Select blue"),
  plotOutput("distPlot")

)


server <- function(input, output) {

   output$distPlot <- renderPlot({
      x    <- faithful[, 2] 
      bins <- seq(min(x), max(x))

      my_color <- "green"
      if (input$button1){my_color <- "red"}
      if (input$button2){my_color <- "blue"}

      hist(x, breaks = bins, col = my_color)
   })
}

shinyApp(ui = ui, server = server)
Run Code Online (Sandbox Code Playgroud)

先感谢您

r shiny shinydashboard action-button

4
推荐指数
1
解决办法
3326
查看次数

标签 统计

r ×2

shiny ×2

action-button ×1

shinydashboard ×1