【发布时间】:2018-03-07 08:42:35
【问题描述】:
这是关于Rshiny的询问。 我创建了一个名为 foo 的函数,如下所示。 在函数中,for 循环中有 5 个绘图。在 Shiny 中绘制绘图时,只有最后一个绘图可见,其余绘图不可见。你没看到正在创建(更新)五个地块吗?
foo <- function(iter = 5){
for(j in 1:iter){
plot(iris$Sepal.Length, iris$Sepal.Width, col = j)
Sys.sleep(0.5)
}
}
ui<-shinyUI(fluidPage(
sth
plotOutput('myplot')
))
server <- shinyServer(function(input, output, session){
sth ...
output$myplot <- renderPlot({
f <- foo(iter = 3)
})
})
})
【问题讨论】:
-
绘图已创建不用担心,它们只是不会呈现给客户端(因为您一直在覆盖它们),如果您想同时显示多个绘图,所有绘图都必须具有唯一的 ID然后为它们分配 ID(例如 plot1、plot2、plot3...)。这里有gist.github.com/wch/5436415 的例子,还有更多的例子
-
@PorkChop Thx,但我想做的是每个情节似乎都被覆盖和更新在一个地方......你能再帮我一次吗?
标签: r shiny interactive