How to create a second dropdown list based on a group of edges with visNetwork in R?
Asked Answered
A

0

13

Similar in spirit to Groups of edges and select in visNetwork in R, I'm wondering how to create a dropdown list based on the edges as opposed to my nodes using the visNetwork package. I think this is possible with the visSetSelection function, but that requires using shiny. I'm delivering the final product in an html rendered from a markdown, not deploying it from a server, so I don't think that's a possibility.

Is there a way to replicate this function outside of shiny? I don't fully understand the terminology in the documentation, but I think what I want to do is similar to the nodeIdSelection or the selectedBy arguments in the visOptions functions where you can create an "HTML select element" but based on the edge list and not on the node list.

The data set for this particular issue is proprietary, but here's some dummy data. I'd like to be able to select by the "weight" of the edge.

   library(tidyverse)
    library(visNetwork)

    nodes <- tibble(id = 1:30)
    edges <- tibble(from = c(21:30, 1:20),
                    to = c(5:20, 21:30, 1:4),
                    weight = c(rep(1:5, 6)))

    visNetwork(nodes, edges) %>%
      visIgraphLayout(layout = "layout_in_circle") %>%
      visOptions(highlightNearest = list(enabled = T, 
                                         hover = T, 
                                         degree = 1, 
                                         algorithm = "hierarchical"), 
                                    nodesIdSelection = T)

What I would expect is an edgesIdSelection argument in visOptions but that isn't an option. I assume that piping visSelectEdges would work, but that only works with shiny and my client doesn't have access to a shiny server. I get that this library was made to make the javascript library accessible through R so I don't expect full functionality--if I can't do this in R with this package (without shiny), I totally get it.

Apteral answered 6/6, 2018 at 15:47 Comment(1)
This seems like a start-to-finish project that you're asking folks to help with, but it's hard to understand what exactly you're trying to do, especially without seeing any code in either of the 2 languages you've tagged. What have you tried so far?Achorn

© 2022 - 2024 — McMap. All rights reserved.