Reputation: 118
I have a folder called logs
filled with different .csv
files, formatted as telemetryLog-2017.21.08.54.11.csv
(with varying dates and times at end).
For example, the above file could be stored like this: file <- read.csv("logs/telemetryLog-1969.2017.21.08.54.11.csv", header=TRUE)
The log files would be uploaded (in the logs
folder, to shinyapps.io
) along with the ui.R
and server.R
files. I would like to be able to obtain a list of the filenames in order to be able to select a file to display as data in a plot via selectInput
(or any other way to list the files). The amount of files in the folder will not be an excessive amount; most likely it will be limited to around 50.
I have read the documentation for shinyFiles
and to be completely honest I do not fully understand how the commands such as fileGetter
or dirGetter
work. Any help would be appreciated.
Upvotes: 2
Views: 2326
Reputation: 25375
Instead of having people browse the file system of your server, you could also use list.files
and specify the right directory there:
library(shiny)
ui <- fluidPage(
selectInput('selectfile','Select File',choice = list.files('log/')),
textOutput('fileselected')
)
server <- function(input,output)
{
output$fileselected <- renderText({
paste0('You have selected: ', input$selectfile)
})
}
shinyApp(ui,server)
Hope this helps!
Upvotes: 3