A year ago I was building a Shiny app and was asking how to display the default folder with shinyFiles.
At this time, with the help of commentators, I built a reproducible example, which was working:
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 = '~'),
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 = {
home <- normalizePath("~")
global$datapath <-
file.path(home, paste(unlist(dir()$path[-1]), collapse = .Platform$file.sep))
})
}
# Run the application
shinyApp(ui = ui, server = server)
Now it's time to update my Shiny app, I updated the R version and a number of packages and it stopped working. I'm getting the following error:
Warning: Error in $: $ operator is invalid for atomic vectors
75: unlist
72: observeEventHandler
1: shiny::runApp
I can't figure out what is wrong now. I tried installing the previous version of shinyFiles but surprisingly still getting the same error. So it must be some other package.
I would appreciate any ideas!
UPD. Adding req(is.list(input$dir)) fixed the problem, now I can the file selection works in the app but if I run it from Docker, I can't see the shared directory...