我有一个闪亮的应用程序,其中我有一个使用 渲染的网络图ggraph
,类似于下面的应用程序:
library(ggraph)
library(igraph)
library(shiny)
ui <- fluidPage(
plotOutput("plot", brush = brushOpts(id = "plot_brush"))
)
server <- function(input, output) {
graph <- graph_from_data_frame(highschool)
output$plot <- renderPlot({
ggraph(graph) +
geom_edge_link(aes(colour = factor(year))) +
geom_node_point()
})
observe(print(
brushedPoints(as_data_frame(graph, what = "vertices"), input$plot_brush)
)
)
}
shinyApp(ui, server)
我要做的是,当您在图表中单击并拖动以捕获某些节点时,我可以检查有关捕获的那些特定点的更多信息。现在,我只是在使用observe({print()})
,以便可以在控制台中看到捕获的内容。
我的问题是,每当我在应用程序中选择一个区域时,无论所选区域中包含多少个节点,控制台都会返回 0 行。如何让它返回所选区域中包含的节点?