Shiny has a nice fileInput() function for allowing the user to browse directories and select the file to upload into the App. Extracted from https://shiny.rstudio.com/reference/shiny/1.7.0/fileInput.html, here's the MWE:
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV file to upload", accept = ".csv"),
checkboxInput("header", "Header", TRUE)
),
mainPanel(
tableOutput("contents")
)
)
)
server <- function(input, output) {
output$contents <- renderTable({
file <- input$file1
ext <- tools::file_ext(file$datapath)
req(file)
validate(need(ext == "csv", "Please upload a csv file"))
read.csv(file$datapath, header = input$header)
})
}
shinyApp(ui, server)
I'm using this in my App for retrieving data, I really like it. However, I'm looking for a similar feature where the user can save a dataframe that results from running the App in a similar way, by browsing directories to choose a location to save the file and selecting a file name. Key is the ability to browse local directories. Any ideas how to accomplish this? Preferably in a way as simple as fileInput().
Files will be .csv, though I'm thinking about .xls too.