Last active
July 21, 2023 19:35
-
-
Save andrie/2a0ee5ac50c4d23906d2 to your computer and use it in GitHub Desktop.
Visualise graph using the networkD3 package
This file contains hidden or 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("networkD3") | |
library("igraph") | |
# Download prepared igraph file from github | |
url <- "https://github.com/andrie/cran-network-structure/blob/master/pdb/depGraph-CRAN.rds?raw=true" | |
datafile <- tempfile(fileext = ".rds") | |
download.file(url, destfile = datafile, mode = "wb") | |
gs <- readRDS(datafile) | |
# Remove all nodes with fewer than 50 edges | |
deg <- degree(gs, mode = "out") | |
idx <- names(which(deg > 50)) | |
gn <- induced.subgraph(gs, idx) | |
# Extract into data frame and plot | |
gd <- get.data.frame(gn, what = "edges") | |
simpleNetwork(gd, fontSize = 12) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment