【问题标题】:R shiny - tabPanel and outputR 闪亮 - tabPanel 和输出
【发布时间】:2017-05-15 17:17:12
【问题描述】:

这是我的代码:

shinyServer <-  function(input, output) {

    output$text_out <- renderText({ 
      paste("You have selected", input$text_input)
    })

  }

shinyUI <- fluidPage(
  titlePanel("censusVis"),
  fluidRow(
    column(3, textInput('text_input', label = 'some label', value ='')),
    column(9,
           tabsetPanel(
               tabPanel('result',
                          fluidRow(
                            column(12, h3('Test_header'),  
                                   textOutput('text_out')
                            )
                          )
                ),
                tabPanel('some panel', tableOutput('table')),
                tabPanel('another panel', tableOutput('table'))

          )
    )
  )

)
shinyApp(ui=shinyUI, server = shinyServer)

它可以工作,但它不显示行"You have selected",如果我在代码tabPanel('another panel', tableOutput('table')) 中注释以下行,则会显示行"You have selected"。你知道怎么回事吗,为什么tabPanel会影响输出?

【问题讨论】:

    标签: r shiny


    【解决方案1】:

    您在两个 tabPanel 中使用相同的输出 tableOutput('table') 两次。这就是为什么它没有显示text_out。使用这个-

    shinyServer <-  function(input, output) {
    
        output$text_out <- renderText({ 
            paste("You have selected", input$text_input)
        })
    
    }
    
    shinyUI <- fluidPage(
        titlePanel("censusVis"),
        fluidRow(
            column(width = 3, textInput('text_input', label = 'some label', value ='')),
            column(width = 9,
                   tabsetPanel(
                       tabPanel(title = 'result',
                                fluidRow(
                                    column(width = 12, 
                                           h3('Test_header'),  
                                           textOutput('text_out')
                                    )
                                )
                       ),
                       tabPanel(title = 'some panel', 
                                tableOutput('table1')
                       ),
                       tabPanel(title = 'another panel',
                                tableOutput('table2')
                       )
                   )
            )
        )
    )
    shinyApp(ui=shinyUI, server = shinyServer)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-06
      • 2017-10-27
      • 2018-02-03
      • 1970-01-01
      • 1970-01-01
      • 2017-04-07
      相关资源
      最近更新 更多