这是我的代码:
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影响输出?
答案 0 :(得分:3)
您在两个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)