RevoScaleR package dependencies with graph visualization

MRAN currently holds 7520 R Packages. We can see this with usage of following command (stipulating that you are using MRAN R version. ):

library(tools)
df_ap <- data.frame(available.packages())
head(df_ap)

2017-03-13 19_38_02-RStudio

With importing package tools, we get many useful functions to find additional information on packages.

Function package.dependencies() parses and check dependencies of a package in current environment. Function package_dependencies()  (with underscore and not dot) will find all dependent and reverse dependent packages.

With following code I can extract the packages and their dependencies (this will perform a data normalization):

net <- data.frame(df_ap[,c(1,4)])
library(dplyr)
netN <- net %>% 
        mutate(Depends = strsplit(as.character(Depends), ",")) %>% 
        unnest(Depends)
netN

And the result is:

Source: local data frame [14,820 x 2]

   Package       Depends
    (fctr)         (chr)
1       A3 R (>= 2.15.0)
2       A3        xtable
3       A3       pbapply
4   abbyyR  R (>= 3.2.0)
5      abc   R (>= 2.10)
6      abc      abc.data
7      abc          nnet
8      abc      quantreg
9      abc          MASS
10     abc        locfit
..     ...           ...

Presented way needs to be further cleaned and prepared.

Once you have data normalized, we can use any of the network packages for visualizing the data. With use of igraph package, I created visual presentation of the RevoScaleR package; dependencies and imported packages.

With the code I filter out the RevoScaleR package and create visual:

library(igraph)
netN_g <- graph.data.frame(edges[edges$src %in% c('RevoScaleR', deptree), ])
plot(netN_g)

2017-03-15 17_01_14-Plot Zoom

 

Happy Ring!

 

 

Advertisements

3 thoughts on “RevoScaleR package dependencies with graph visualization

  1. Thanks for this great post! A couple comments:

    1. Using `unnest` requires `tidyr` to be loaded
    2. The code produces this error:
    “`
    > netN_g <- graph.data.frame(edges[edges$src %in% c('RevoScaleR', deptree), ])
    Error in edges$src : object of type 'closure' is not subsettable
    “`

    Thoughts?

    Like

  2. Yes, there is a portion of the code missing on the blog post – part of data wrangle is missing. 🙂

    library(tools)
    library(plyr)
    library(igraph)

    #pkgs <- available.packages()
    pkgs <- installed.packages()

    ##

    edges <- ldply(c('Depends', 'Imports', 'Suggests'), function(depLevel) {
    deps <- package.dependencies(pkgs, depLevel = depLevel)

    RevoScaleR.graph <- graph.data.frame(edges[edges$src %in% c('RevoScaleR', deptree), ])
    plot(RevoScaleR.graph)

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s