File Upload to select among a list of .csv files stored locally within the shiny folder

Hi everyone,

I am not new to shiny but definitely very bad at it as you are about to find out. I want to change this example so that the user can only select a .csv from a quite large list of individual .csv files that I have stored locally within the shiny folder ("./data").

(I think) this is easy at least for me if the choice was to be made among the different columns of a single .csv file.

Thank you in advance for your help

     if (interactive()) {

    ui <- fluidPage(
         fileInput("file1", "Choose CSV File",
           accept = c(
      checkboxInput("header", "Header", TRUE)

server <- function(input, output) {
  output$contents <- renderTable({
    # input$file1 will be NULL initially. After the user selects
    # and uploads a file, it will be a data frame with 'name',
    # 'size', 'type', and 'datapath' columns. The 'datapath'
    # column will contain the local filenames where the data can
    # be found.
    inFile <- input$file1

    if (is.null(inFile))

    read.csv(inFile$datapath, header = input$header)

shinyApp(ui, server)

I don't think you will want to use the fileInput function in this case as the user is not going to be uploading any files.

You can more likely modify this code to get what you want as it has an example of choosing among pre-populated datasets:

You will just need to specify where the datasets are (I am still new, but I think they would go in your WWW folder and would then be accessible).

Thanks for your help, I did try selectInput and that is more likely what I need, as you say.

My problem is that I know how to use this for creating a selection among different columns of a dataframe.

However, what I want is to create a selection among different .csv files within the same data folder

I think you have to put the data you want to include in the app in a folder called "Data", and then

df1 <- read.csv("./Data/df1.csv")
df2 <- read.csv("./Data/df2.csv")

And so on... You may find this article useful:

Thanks for your help, your advice has been definetly helpful and sent me on the right path, but still I have not been able to implement it. I have posted a perhaps more reproducible example here with my latest attempt to figure it out:

I will make sure to cross-reference both posts once it is resolved