Thanks for the help! I actually had to try and merge this with a tutorial I was following in order to get the 'copy' and 'download' buttons working correctly. Now I'm happy with the result but I've lost the 'server'/action part of the drop down menu...at least I think that's the problem. Below is the code I have now, where I incorporated your comments to get the dropdown of choosing "DATASET1",2,3. But I couldn't get the second part to integrate correctly in the server section - aka nothing happens when you choose a different dataset. Here's the code now, with only the dropdown part in the 'ui' section :
library(shiny)
library( DT )
# Define UI for application that creates a datatables
ui <- fluidPage(fluidRow(selectInput("TheFile", "Select Cohort",
choices = c("DATASET1.csv", "DATASET2.csv", "DATASET3.csv"))),
fluidRow(column(12, div(dataTableOutput("dataTable")))),
# Application title
titlePanel("Download Datatable")
# Show a plot of the generated distribution
, mainPanel(
DT::dataTableOutput("fancyTable")
) # end of main panel
) # end of fluid page
# Define server logic required to create datatable
server <- function(input, output, session) {
myCSV <- reactive({
read.csv(input$TheFile)
})
output$fancyTable <- DT::renderDataTable(
datatable( data = read.csv("DATASET1.csv")
, extensions = 'Buttons'
, options = list(
dom = "Blfrtip"
, buttons =
list("copy", list(
extend = "collection"
, buttons = c("csv", "excel", "pdf")
, text = "Download"
) ) # end of buttons customization
# customize the length menu
, lengthMenu = list( c(10, 20, -1) # declare values
, c(10, 20, "All") # declare titles
) # end of lengthMenu customization
, pageLength = 10
) # end of options
) # end of datatables
)
} # end of server
# Run the application
shinyApp(ui = ui, server = server)