Closed zhenglei-gao closed 5 years ago
I could not find someone having the same the problem but it seems after I select the root drive and then the target folder, only the name of the root drive is returned and what I can get by selecting the folder is
"EFM (V:)/XXX/2016/Effect modelling/"
I need the V: instead of EFM (V:)
V:
EFM (V:)
Below is the code I used:
library(shiny) library(shinyFiles) ui <- fluidPage( # Application title mainPanel( shinyDirButton("dir", "Input directory", "Upload"), verbatimTextOutput("dir", placeholder = TRUE) )) server <- function(input, output) { shinyDirChoose( input, 'dir', ## roots = c(home = 'C:/'), roots = getVolumes()() ##filetypes = c('', 'txt', 'bigWig', "tsv", "csv", "bw") ) global <- reactiveValues(datapath = getwd()) dir <- reactive(input$dir) output$dir <- renderText({ global$datapath }) observeEvent(ignoreNULL = TRUE, eventExpr = { input$dir }, handlerExpr = { if (!"path" %in% names(dir())) return() #home <- normalizePath("~") # browser() global$datapath <-file.path(dir()$root,paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep)) #file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep)) }) } # Run the application shinyApp(ui = ui, server = server)
I think I found the answer.
should beparseDirPath(root, input$directory)
parseDirPath(root, input$directory)
I could not find someone having the same the problem but it seems after I select the root drive and then the target folder, only the name of the root drive is returned and what I can get by selecting the folder is
"EFM (V:)/XXX/2016/Effect modelling/"
I need the
V:
instead ofEFM (V:)
Below is the code I used: