我正在开发一个 Shiny 应用程序,该应用程序允许用户选择一个文件夹,shinyFiles::shinyDirChoose()
然后使用visNetwork
. 除非我包含图标 / addFontAwesome()
,否则一切正常,在这种情况下shinyDirChoose()
不显示文件夹和文件。是否有修复,或者这是一个错误?如果是后者,是哪个包,shinyFiles
还是visNetwork
?
这是一个MWE。在本例中,为简单起见,选择文件夹与可视化无关,但仍会重现错误。该示例基于visNetwork
此处找到的示例:https ://datastorm-open.github.io/visNetwork/image_icon.html并运行shinyFiles::shinyFilesExample()
library(magrittr)
server <- function(input, output) {
volumes <- shinyFiles::getVolumes()
shinyFiles::shinyDirChoose(input, "directory", roots=volumes)
output$directorypath <- shiny::renderPrint({shinyFiles::parseDirPath(volumes, input$directory)})
output$network <- visNetwork::renderVisNetwork({
nodes <- data.frame(id = 1:5, group = c(rep("A", 2), rep("B", 3)))
edges <- data.frame(from = c(2,5,3,3), to = c(1,2,4,2))
visNetwork::visNetwork(nodes, edges, width = "100%") %>%
visNetwork::visGroups(groupname = "A", shape = "icon",
icon = list(code = "f0e3", color = "darkblue")) %>%
visNetwork::visGroups(groupname = "B", shape = "icon",
icon = list(code = "f000", color = "red")) %>%
visNetwork::addFontAwesome()
})
}
ui <- fluidPage(
shinyFiles::shinyDirButton("directory", "Folder select", "Please select a folder"),
shiny::verbatimTextOutput("directorypath"),
visNetwork::visNetworkOutput("network")
)
shiny::shinyApp(ui = ui, server = server)
如果图标块被删除,即visGroups
行更改为:
visNetwork::visGroups(groupname = "A", color = "darkblue") %>%
visNetwork::visGroups(groupname = "B", color = "red")
它工作正常。(visNetwork::addFontAwesome()
线路不是问题。)
我很困惑。