【问题标题】:Don't replot everything in a Shiny output block不要重新绘制闪亮输出块中的所有内容
【发布时间】:2019-04-26 15:09:56
【问题描述】:

我在使用取决于两个不同输入的 plotOutput 时遇到了一些问题。我需要找到一种方法来修改取决于第二个输入的绘图块部分,而无需重新绘制所有内容。

我的情节块是这样的:

output$some_output<-renderPlot({
    im<-load.image(input$a)
    plot(im)
    if(input$b == something){
        points(1,2) //or anything over that image plot
    }
})

我需要的是在 input$b 更改时以某种方式不重新绘制图像。不久前我开始使用 Shiny,所以我仍然不了解它具有的每个反应功能。欢迎任何想法。

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    使用isolate(),这将删除input$b 的反应性,并且仅在input$a 更改时更新绘图。参考可以在这里找到https://shiny.rstudio.com/articles/isolation.html

    output$some_output<-renderPlot({
        im<-load.image(input$a)
        plot(im)
        if(isolate(input$b) == something){
            points(1,2) //or anything over that image plot
        }
    })
    

    将来,最好提供一个完整的工作示例,以便人们进行测试以确保解决方案有效。

    【讨论】:

    • 没问题!如果它对您有用,请记得点击复选标记说您有答案,以便其他人可以从中学习。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-27
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    • 2023-04-01
    • 2021-07-17
    相关资源
    最近更新 更多