【问题标题】:Shiny : how to show that a graph is deprecated闪亮:如何显示图表已被弃用
【发布时间】:2015-06-01 23:53:59
【问题描述】:

我在 Shiny 中有一个反应式绘图 (renderPlot),它依赖于大量用户输入并且需要大量计算。我使用以下方法隔离了图表:

output$myGraph <- renderPlot({
  input$goButton
  isolate({
    myFunction(input$var1, .... input$varn)
  })
})

不过,我想在用户更改单个输入时立即向他提供一个指示,即当前图表不是最新的。 关于如何在不检查所有输入的情况下执行此操作的任何想法?

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    我建议您在 Shiny Server 中创建另一个输出变量,一旦您的图表被弃用,它就会显示图像(或其他)。为了使该指标在正确的时间显示,您创建了一个响应值(您自己创建的值并且像 input$ 变量一样工作),该值根据所有输入更改获取弃用标志。绘制图表后,您将重置弃用标志。

    # Only called when applications starts
    values <- reactiveValues()
    values$deprecated <- -1 
    
    # Function that depends on all input variables and sets deprecation flag
    computeDeprecation <- reactive({ 
        input$...
        ...
        input$...
        #activate deprecation
        values$deprecated <- 1 
    
    
    })
    
    # function that depends on deprecationflag (only if it changes, not everytime
    # computeDeprecation() is called) and outputs and deprecation indicator
    output$indication<- renderImage({
        if(values$deprecated != 1){
            return()
        }
        #show deprecation indicator
    })
    
    output$myGraph <- renderPlot({
      input$goButton
      isolate({
         myFunction(input$var1, .... input$varn)
         # reset deprecated variable
         values$deprecated <- 1
      })
    })
    

    【讨论】:

      猜你喜欢
      • 2017-01-31
      • 1970-01-01
      • 2019-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-14
      • 2014-05-13
      相关资源
      最近更新 更多