【发布时间】:2021-12-11 11:53:47
【问题描述】:
我的 Shiny 主面板中有 uiOutput 和 plotOutput 组件。
plotOutput("plot_data"),
uiOutput("summary_data")
我在服务器函数中有典型的代码来响应和填充每个组件,例如:
output$plot_data <- renderPlot({
hist(data_vars())
})
output$summary_data <- renderPrint({
summary(data_vars())
})
我想为每个添加功能,将另一个的输出组件设置为 NULL 或空字符串等,以便这两个输出共享相同的空间。当一个有数据时,另一个是空的。我不认为它会以这种方式工作,但它可能看起来像这样:
output$plot_data <- renderPlot({
# Code to "flatten" uiOutput
# Then populate the component
hist(data_vars())
})
output$summary_data <- renderPrint({
# Code to "flatten" plotOutput
# Then populate the component
summary(data_vars())
})
我认为这可以使用 observeEvent 来完成,但我还没有找到一种方法来完全删除其中的内容,以便另一个可以占用页面上的相同空间。请帮忙。谢谢。
【问题讨论】:
标签: r user-interface shiny server