r - 闪亮的 FilesButton 开始目录
问题描述
我有一个闪亮的应用程序,用户必须在其中选择要进一步处理的文件。shinyFilesButton 让我可以做到这一点——但是,文件选择总是从根目录开始(在我的例子中是 C:)。是否可以让文件选择从特定目录开始?例如,我希望文件选择从“C:\Users\admin\Documents”开始
这将大大提高可用性。
预先感谢!帕特里克
MWE
library(shiny)
# Define UI ----
ui <- fluidPage(
shinyFilesButton("filePath", "Please Select File", title = "Select File", multiple = FALSE,
buttonType = "default", class = NULL),
br(),
br(),
textOutput("inputFile")
)
# Define server logic ----
server <- function(input, output, session) {
volumes = getVolumes()
observe({
shinyFileChoose(input, "filePath", roots = volumes, session = session)
if(!is.null(input$filePath)){
# browser()
input_file_selected <- parseFilePaths(volumes, input$filePath)
output$inputFile <- renderText({
paste("File Path: ", as.character(input_file_selected$datapath))
})
}
})
}
# Run the app ----
shinyApp(ui = ui, server = server)
解决方案
这是roots
选项的作用:
shinyFileChoose(input, "filePath", roots = c(Documents = "C:/Users/admin/Documents"), session = session)
推荐阅读
- android - Android - 应用程序可能在其主线程上做太多工作 - Fragment,RecyclerView
- python - 将一个非常大的数据框的列拆分为两个(或更多)新列
- cmake - 错误:未定义对 cv::imwrite 的引用,这里有什么问题?
- reactjs - 如何在更改时更新 React State
- emulation - 加倍位 gb-emu
- python - 层 max_pooling2d 的输入 0 与层不兼容:预期 ndim=4,发现 ndim=5。收到的完整形状:[None, 4, 10, 8, 32]
- amazon-web-services - 在 AWS 上查看我的免费套餐的使用量
- python - malloc():未排序的双链表损坏中止(核心转储)python
- css - Angular:将类添加到跨度选择器
- sql - 选择 MIN MAX 一起改变查询的行为