I have:
library(shiny)
library(DT)
ui <- fluidPage(
h2("Explorer"),
tabPanel(h3("Inspector"),
p("Overview of data for a particular sample."),
selectInput(inputId = "sample",
label = h3("Select sample"),
selectize = TRUE,
choices = names(vcf_tibbles)),
dataTableOutput("sample_inspector")
)
)
server <- function(input, output) {
output$sample_inspector <- DT::renderDataTable(
sammple_overview(sample_id = input$sample, vcf_tibbles = vcf_tibbles),
rownames = FALSE,
extensions = 'Buttons',
options = list(paging = FALSE,
dom = 'Bfrtip',
buttons = list( list(extend = 'csv', filename = paste("snp", input$sample, sep = "-")),
list(extend = 'excel', filename = paste("snp", input$sample, sep = "-"))))
)
}
Everything works fine, in that I select a sample and the table correspondingly updates. And if I click CSV or Excel, the corresponding dta downloads. However, the file name is always wrong.
It seems that the content of the data table is being updated, but input$sample
is not being considered with the buttons.
Is there a way to make the filename argument in the buttons also be reactive?
I tried to make the name be the result of a function call, but was unable to get that to work either.
Thanks!