从 R 闪亮的文件路径列表中选择子文件夹时,'closure' 类型对象的错误不可子集化
Error of object of type 'closure' is not subsettable when choosing sub-folder from R shiny list of file paths
如何修改代码以允许在用户中导航子文件夹?
我找不到我需要在用户下使用代码如下的子文件夹。
当我单击 'Users' 查找子文件夹或被选中时,Warning: Error in [: object of type 'closure' is not subsettable [No stack trace available]
出现。
ui <- fluidPage(
shinyDirButton("Btn_GetFolder", "Choose a folder" ,
title = "Please select a folder:",
buttonType = "default", class = NULL),
textOutput("txt_file")
)
server <- function(input,output,session){
volumes = getVolumes()
observe({
shinyDirChoose(input, "Btn_GetFolder", roots = volumes, session =
session)
if(!is.null(input$Btn_GetFolder)){
# browser()
myInputDir1 <- parseDirPath(volumes, input$Btn_GetFolder)
listBands <- list.files(myInputDir1, full.names = T)
output$txt_file <- renderText(listBands)
#Call function here.....
}
})
}
shinyApp(ui = ui, server = server)
getVolumes
的帮助在“值”部分指出:
A function returning a named vector of available volumes
因此,volume
是一个函数,需要计算为 return 可用体积。这也解释了你得到的错误:仅仅使用 volumes
意味着你实际上提供了一个函数(基本上是一个闭包),然后在 shinyDirChoose
的某个地方它被子集化 - 这是行不通的。
library(shiny)
library(shinyFiles)
ui <- fluidPage(
shinyDirButton("Btn_GetFolder", "Choose a folder" ,
title = "Please select a folder:",
buttonType = "default", class = NULL),
textOutput("txt_file")
)
server <- function(input,output,session){
volumes = getVolumes()
observe({
shinyDirChoose(input, "Btn_GetFolder", roots = volumes(), session =
session)
if(!is.null(input$Btn_GetFolder)){
# browser()
myInputDir1 <- parseDirPath(volumes, input$Btn_GetFolder)
listBands <- list.files(myInputDir1, full.names = T)
output$txt_file <- renderText(listBands)
#Call function here.....
}
})
}
shinyApp(ui = ui, server = server)
如何修改代码以允许在用户中导航子文件夹?
我找不到我需要在用户下使用代码如下的子文件夹。
当我单击 'Users' 查找子文件夹或被选中时,Warning: Error in [: object of type 'closure' is not subsettable [No stack trace available]
出现。
ui <- fluidPage(
shinyDirButton("Btn_GetFolder", "Choose a folder" ,
title = "Please select a folder:",
buttonType = "default", class = NULL),
textOutput("txt_file")
)
server <- function(input,output,session){
volumes = getVolumes()
observe({
shinyDirChoose(input, "Btn_GetFolder", roots = volumes, session =
session)
if(!is.null(input$Btn_GetFolder)){
# browser()
myInputDir1 <- parseDirPath(volumes, input$Btn_GetFolder)
listBands <- list.files(myInputDir1, full.names = T)
output$txt_file <- renderText(listBands)
#Call function here.....
}
})
}
shinyApp(ui = ui, server = server)
getVolumes
的帮助在“值”部分指出:
A function returning a named vector of available volumes
因此,volume
是一个函数,需要计算为 return 可用体积。这也解释了你得到的错误:仅仅使用 volumes
意味着你实际上提供了一个函数(基本上是一个闭包),然后在 shinyDirChoose
的某个地方它被子集化 - 这是行不通的。
library(shiny)
library(shinyFiles)
ui <- fluidPage(
shinyDirButton("Btn_GetFolder", "Choose a folder" ,
title = "Please select a folder:",
buttonType = "default", class = NULL),
textOutput("txt_file")
)
server <- function(input,output,session){
volumes = getVolumes()
observe({
shinyDirChoose(input, "Btn_GetFolder", roots = volumes(), session =
session)
if(!is.null(input$Btn_GetFolder)){
# browser()
myInputDir1 <- parseDirPath(volumes, input$Btn_GetFolder)
listBands <- list.files(myInputDir1, full.names = T)
output$txt_file <- renderText(listBands)
#Call function here.....
}
})
}
shinyApp(ui = ui, server = server)