This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Inconsistency in shinyFiles output.

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.

shinyfiles shinyapp server.r

EDIT:

server.R

shinyServer(function(input, output, session){
...

      dataFolder <- NULL ## directory path

      ## Validating path and confirming upload

      output$filepaths <- renderText({
        shinyFileChoose(input, "files", roots= getVolumes(), session=session, filetypes=c('','bed'))
        dataFolder <<- paste0(dirname(parseFilePaths(roots=getVolumes(), input$files)$datapath), "/") ## Store folder location
        return(dataFolder)
        })

...
    })

P.S. There has been some success with this tweak and the error is no more. However, this dialog box from shinyFilesChoose is blank. No folders are listed. The working code (above) still works in isolation. Just to clarify, the shinyDirChoose() functionality has been glossed over due to some other issue.

Hello Shaurya Jauhari!

We believe that this post does not fit the main topic of this site.

This is a question on shiny, and has little to do with bioinformatics. The answer would not be any different were you asking for locations of PNG files.

For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.

If you disagree please tell us why in a reply below, we'll be happy to talk about it.

Cheers!

0 answers

No answers yet.

Log in to answer this question.