Reputation: 23630
Shiny seems to only accept the final output of any provided to mainPanel
in ui.R
. An earlier SO question raised this but reached no satisfactory solution. The documentation for mainPanel suggests this should be possible:
Description: Create a main panel containing output elements
The following code illustrates:
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?")
})
)
Does anyone know if this is a bug, or how to work around it?
Upvotes: 4
Views: 10948
Reputation: 10215
Try
mainPanel(
# only the last output works
h1(textOutput("txt")),
plotOutput("myplot"),
p("see what I mean?")
)
Upvotes: 5