我正在制作一个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()
行不是问题。)
我很困惑。