Shiny 似乎只接受任何提供给的最终输出mainPanel
in ui.R
. An 较早的问题 https://stackoverflow.com/questions/22996434/adding-more-than-one-graph-to-mainpanel-in-shiny-r提出了这个问题,但没有达成令人满意的解决方案。 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?")
})
)
有谁知道这是否是一个错误,或者如何解决它?
Try
mainPanel(
# only the last output works
h1(textOutput("txt")),
plotOutput("myplot"),
p("see what I mean?")
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)