【发布时间】:2016-08-18 14:27:00
【问题描述】:
我正在尝试做一个shiny 应用程序来下载过滤后的Datatable:
- 使用
searsh过滤 - 通过删除带有
delete button的行进行过滤
(下载部分按预期工作)
问题:当我第一次使用数据表中的搜索区域进行过滤时,如果我使用按钮删除一行,它会重置第一个过滤器
我的可复制示例:编辑工作解决方案
library(shinydashboard)
library(DT)
library(shiny)
ui <- dashboardPage(
dashboardHeader(title = "Info boxes"),
dashboardSidebar(),
dashboardBody(
fluidRow(DT::dataTableOutput('data')),
fluidRow(p(class = 'text-center', downloadButton('x3', 'Download Filtered Data')))
)
)
server <- function(input, output) {
df <- reactiveValues(data = data.frame(
Value1 = 1:10,
Value2 = c("A", "B", "C", "D", "E"),
stringsAsFactors = FALSE,
row.names = 1:10
))
output$data <- DT::renderDataTable(
df$data, server = TRUE, filter = 'top', escape = FALSE, selection = 'none')
# download the filtered data
output$x3 = downloadHandler('emergence filtré.csv', content = function(file) {
s = input$data_rows_all
write.table(df$data[s,], file ,sep=";",row.names = F)
})
}
shinyApp(ui = ui, server = server)
谢谢
【问题讨论】:
标签: r download datatables shiny dt