【发布时间】:2023-04-06 14:43:02
【问题描述】:
我和我的朋友刚接触闪亮。
我们正在努力自学闪亮。除了一个大大小小的问题,一切都很好。
最大的问题是:为什么我们不能用renderTable() 显示表格?我们只能显示年份范围。
小问题是:我们可以在相关图中显示侧边栏标签而不是在 csv 中分配的标签吗?
非常感谢。
library(shiny)
library(shinydashboard)
ui <- fluidPage(sidebarLayout(
sidebarPanel
(
checkboxGroupInput(
"feature",
"Feature",
c(
"No of case" = "no_case",
"Minor Case" = "minor_case",
"All Non Fatal Case" = "all_non_fatl",
"Fatal Case" = "fatal_case"
)
),
sliderInput(
"year",
"Year",
min = 2015,
max = 2021,
value = c(2015, 2021)
)
),
mainPanel(tabsetPanel(
tabPanel("Plot", plotOutput("correlation_plot")),
tabPanel("Table", tableOutput("ecd"))
))
))
server <- function(input, output) {
yearrange <- reactive({
input$year[1]:input$year[2]
})
output$correlation_plot <- renderPlot({
validate(need(input$feature, 'Check one of these items.'))
plot(ecd$year,
ecd[[input$feature]],
xlab = "Year",
ylab = input$feature) #how not to show tab name but show the side bar name
})
output$ecd <- renderTable({
yearrange()
})
}
shinyApp(ui, server)
【问题讨论】: