Я бы хотел, чтобы пользователь мог выбрать папку (я найду путь для этого позже).
На данный момент это работает для выбора файла, но не папки. Я не могу объяснить, почему. И в каталоге есть файлы (проверено на Windows и Mac).
Есть идеи?
library(shiny)
library(shinyFiles)
ui <- fluidPage(
shinyFilesButton("Btn_GetFile", "Choose a file" ,
title = "Please select a file:", multiple = FALSE,
buttonType = "default", class = NULL),
shinyDirButton('folder', 'Folder select', 'Please select a folder', FALSE),
textOutput("txt_file")
)
server <- function(input,output,session){
volumes = getVolumes()
observe({
shinyFileChoose(input, "Btn_GetFile", roots=volumes, session = session)
if(!is.null(input$Btn_GetFile)){
# browser()
file_selected<-parseFilePaths(volumes, input$Btn_GetFile)
output$txt_file <- renderText(as.character(file_selected$datapath))
}
})
observe({
if(!is.null(input$Btn_Folder)){
# browser()
shinyDirChoose(input, 'folder', roots=volumes)
dir <- reactive(input$folder)
output$dir <- renderText(as.character(dir()))
}
})
}
shinyApp(ui = ui, server = server)