Last active
June 6, 2021 06:00
-
-
Save hinkelman/df2422122a4a0588973dd2af443a1100 to your computer and use it in GitHub Desktop.
Shiny app referenced in https://www.travishinkelman.com/visualize-scheme-library/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(dplyr) | |
library(visNetwork) | |
edges <- readr::read_tsv("https://raw.githubusercontent.com/hinkelman/dataframe/master/network-graph/Edges.tsv", | |
col_names = FALSE) %>% | |
setNames(c("from", "to")) | |
nodes <- readr::read_tsv("https://raw.githubusercontent.com/hinkelman/dataframe/master/network-graph/Nodes.tsv", | |
col_names = FALSE) %>% | |
setNames(c("label", "id")) %>% | |
left_join(readr::read_tsv("https://raw.githubusercontent.com/hinkelman/dataframe/master/network-graph/NodesByFile.tsv", | |
col_names = FALSE) %>% | |
setNames(c("group", "label"))) %>% | |
# not a fan of the default legend look; so putting that information in title, which is available through hover/click | |
mutate(title = paste0(label, "<br>", group)) | |
# Define UI for application that draws a histogram | |
ui <- fluidPage( | |
fluidRow(col = 12, visNetworkOutput("networkGraph", height = "800px")) | |
) | |
# Define server logic required to draw a histogram | |
server <- function(input, output) { | |
output$networkGraph <- renderVisNetwork({ | |
nodes %>% | |
visNetwork(edges) %>% | |
visEdges(arrows = "to") %>% | |
visOptions(highlightNearest = TRUE, | |
nodesIdSelection = TRUE) | |
}) | |
} | |
# Run the application | |
shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment