Entering edit mode
4.0 years ago
Shaurya Jauhari
▴
50
Hi there.
My objective is to record a folder path that contains BED files. The user is required to browse to the folder and choose any BED file. On doing that the absolute path to that folder gets recorded. I have a working code below.
ui <- shinyUI(bootstrapPage(
shinyFilesButton('files','Folder select','Please select a BED file', FALSE),
verbatimTextOutput('filepaths')))
server <- shinyServer(function(input, output) {
roots = getVolumes()
shinyFileChoose(input,'files', roots=roots, filetypes=c('','bed'))
output$filepaths <- renderText({paste0(dirname(parseFilePaths(roots, input$files)$datapath), "/")})})
runApp(list(ui=ui,server=server))
Although, when I try to incorporate it into my actual script, an error is returned.
Warning: Error in list.files: invalid 'path' argument
The excerpts from the ui.R and server.R are as under, respectively.
ui.R
shinyUI(fluidPage(theme = shinytheme("united"),
...
sidebarLayout("", fluid = TRUE,
sidebarPanel(
shinyFilesButton('files','Folder select','Please select a BED file', FALSE),
verbatimTextOutput('filepaths', placeholder = TRUE),
...
))
server.R
shinyServer(function(input, output, session){
...
dataFolder <- NULL
## Validating path and confirming upload
roots <- getVolumes()
shinyFileChoose(input,'files', roots=roots, filetypes=c('','bed'))
dataFolder <<- reactive({paste0(dirname(parseFilePaths(roots, input$files)$datapath), "/")}) ## Store folder location
output$filepaths <- renderText({dataFolder})
...
})
Any suggestions? Thanks.