请给我形象,我有这个程序
library(shiny)
library(DT)
library(shinydashboard)
my_data <- head(mtcars)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
fluidRow(
box(DT::dataTableOutput("table1"))
)
)
)
server <- function(input, output) {
output$table1 <- DT::renderDataTable({
datatable(my_data)
})
}
shinyApp(ui, server)
我希望人们能够从我的应用程序下载呈现的表,但是我不知道如何向我的应用程序添加下载功能和下载按钮;有帮助吗?
答案 0 :(得分:0)
server <- function(input, output){
output[["table1"]] <- renderDT({
datatable((my_data), editable = "cell", extensions = "Buttons",
options = list(
dom = "Bfrtip",
buttons = list(
"csv"
)
))
})
observeEvent(input[["table_cell_edit"]], {
cellinfo <- input[["table_cell_edit"]]
dat <<- editData(dat, input[["table_cell_edit"]], "table1")
})
}