Shiny似乎只接受在
ui.R
中提供给mainPanel
的最终输出。一个早期的SO问题提出了这个问题,但没有得到令人满意的解决方案。 mainPanel的文档表明应该是可能的:
下面的代码说明了这一点: server.R描述:创建包含输出元素的主面板
library(shiny)
shinyServer(
function(input, output) {
plotInput <- reactive({
list(plot = plot(1:10),
txt = "My reactive title")
})
output$myplot <- renderPlot({ plotInput()$plot })
output$txt <- renderText({ plotInput()$txt })
}
)
ui.R
require(shiny)
pageWithSidebar(
headerPanel("Multiple outputs to mainPannel"),
sidebarPanel(),
mainPanel({
# only the last output works
h1(textOutput("txt"))
plotOutput("myplot")
p("see what I mean?")
})
)
有人知道这是一个bug吗?还是有什么方法可以解决它?
plotInput()$plot
方法从reactive()
中提供多个输出有什么看法?如果有更好的方法,我很感兴趣听听。 - geotheory