Skip to content

Instantly share code, notes, and snippets.

@gmonaie
Created June 13, 2013 22:53
Show Gist options
  • Save gmonaie/5778107 to your computer and use it in GitHub Desktop.
Save gmonaie/5778107 to your computer and use it in GitHub Desktop.
R: dependsOnPkgsGraph
library(tools)
library(foreach)
library(iterators)
library(rCharts)
library(slidify)
library(slidifyLibraries)
library(doParallel)
library(d3Network)
package <- grep("^package:", search(), value = TRUE)
keep <- sapply(package, function(x) x == "package:base" ||
!is.null(attr(as.environment(x), "path")))
package <- sub("^package:", "", package[keep])
# packagedb = available.packages(contriburl="http://R-Forge.R-project.org")
# grab the package dependencies
# x = foreach(p=iter(package), .combine='c') %do%
# {package_dependencies(p, db=packagedb, recursive=TRUE)}
x = foreach(p=iter(package)) %do% {dependsOnPkgs(p, recursive=FALSE)}
names(x) = package
# x = lapply(x, function(x) if(is.null(x)){"NA"} else {x})
# parse them into Source and Targets
Source = foreach(i=1:length(x), .combine='c') %do% {rep(names(x[i]),length(x[[i]]))}
Target = (foreach(i=1:length(x), .combine='c') %do%{x[[i]]})
NetworkData <- data.frame(Source, Target)
# Load packages to download d3SimpleNetwork
library(digest)
library(devtools)
# Download d3SimpleNetwork
# source_gist("5734624")
d3SimpleNetwork(NetworkData, height = 800, width = 1280, file='myPackages.html')
@gmonaie
Copy link
Author

gmonaie commented Jun 13, 2013

Shows you your package dependencies using the d3SimpleNetwork package by Christopher Gandrud http://christophergandrud.github.io/d3Network/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment