我正在尝试使用R和闪亮包制作交互式报告。 我有一个数据框,需要按国内,国外塔斯曼和国际旅行价值分别显示在3个表格中。 此外,我需要根据总金额,asp和细分计数值仅用前10行显示所有这些值,并且这些值中的每一个都在表底部具有总计。
这是我的代码:
server <- shinyServer(function(inputcp, outputcp) {
# Filter data based on selections
outputcp$table <- DT::renderDataTable(DT::datatable({
datacp <- city.pair
if (inputcp$fis.year != "All") {
datacp <- datacp[datacp$fis_year == inputcp$fis.year,]
}
if (inputcp$fis.quarter != "All") {
datacp <- datacp[datacp$fis_quarter_name == inputcp$fis.quarter,]
}
if (inputcp$region != "All") {
datacp <- datacp[datacp$region_desc.x == inputcp$region,]
}
datacp
}))
}
)
ui <- shinyUI(fluidPage(
titlePanel("City Pair"),
# Create a new Row in the UI for selectInputs
fluidRow(
column(4,
selectInput("fis.year",
"Fis Year:",
c("All",
unique(as.character(city.pair$fis_year))))
),
column(4,
selectInput("fis.quarter",
"Fis Quarter:",
c("All",
unique(as.character(city.pair$fis_quarter_name))))
),
column(4,
selectInput("region",
"Region:",
c("All",
unique(as.character(city.pair$region_desc.x))))
)
),
# Create a new row for the table.
fluidRow(
DT::dataTableOutput("table")
)
))
shinyApp(ui = ui, server = server)
非常感谢您的帮助和建议,谢谢。