闪亮-多个输出到mainPanel

geo*_*ory 4 r shiny

Shiny似乎只接受mainPanelin中提供的任何最终输出ui.R。一个较早的SO问题提出了这个问题,但没有得到令人满意的解决方案。mainPanel的文档建议应该可行:

描述:创建一个包含输出元素的主面板

以下代码说明:

服务器

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 })
  }
)
Run Code Online (Sandbox Code Playgroud)

用户界面

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?")
  })
)
Run Code Online (Sandbox Code Playgroud)

有谁知道这是一个错误,还是如何解决?

Die*_*nne 5

尝试

  mainPanel(
    # only the last output works
    h1(textOutput("txt")),
    plotOutput("myplot"),
    p("see what I mean?")
  )
Run Code Online (Sandbox Code Playgroud)

  • 别这样 令人讨厌的嵌套和令人困惑的错误消息使Shiny成为快乐的调试冒险(即使它是经过精心设计的)。 (4认同)
  • 我很尴尬! (2认同)