https://github.com/ikosmidis/cranly
Package directives and collaboration networks in CRAN
https://github.com/ikosmidis/cranly
cran-r network-analysis network-visualization rstats
Last synced: 3 months ago
JSON representation
Package directives and collaboration networks in CRAN
- Host: GitHub
- URL: https://github.com/ikosmidis/cranly
- Owner: ikosmidis
- Created: 2018-03-25T18:00:52.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T13:41:55.000Z (about 3 years ago)
- Last Synced: 2024-04-25T17:21:42.712Z (over 1 year ago)
- Topics: cran-r, network-analysis, network-visualization, rstats
- Language: R
- Homepage:
- Size: 178 MB
- Stars: 49
- Watchers: 4
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- jimsghstars - ikosmidis/cranly - Package directives and collaboration networks in CRAN (R)
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "inst/README_files/README-",
cache.path = "inst/README_cache/README-",
fig.width = 7,
fig.height = 7
)
```[](https://travis-ci.org/ikosmidis/cranly)
[](https://codecov.io/github/ikosmidis/cranly?branch=master)
[](https://cran.r-project.org/package=cranly)
[](https://www.gnu.org/licenses/gpl-3.0.en.html)# cranly
[**cranly**](https://github.com/ikosmidis/cranly) provides core visualizations and summaries for the CRAN package database. It is aimed mainly as an analytics tool for developers to keep track of their CRAN packages and profiles, as well as those of others, which, at least for me, is proving harder and harder with the rapid growth of the [CRAN](https://cran.r-project.org) ecosystem.
The package provides methods for cleaning up and organizing the information in the CRAN package database, for building package directives networks (depends, imports, suggests, enhances, linking to) and collaboration networks, and for computing summaries and producing interactive visualizations from the resulting networks. Network visualization is through the [**visNetwork**](https://CRAN.R-project.org/package=visNetwork) package. The package also provides functions to coerce the networks to [igraph](https://CRAN.R-project.org/package=igraph) objects for further analyses and modelling.
### Installation
Install the development version from github:
``` r
# install.packages("devtools")
devtools::install_github("ikosmidis/cranly")
```### Collaboration and package directives networks in CRAN
Load **cranly** as
```{r}
library("cranly")
```The first step in the **cranly** workflow is to try and
"clean-up" the package and author names in the data frame that results
from a call to `tools::CRAN_package_db()`
```{r cache = TRUE}
p_db <- tools::CRAN_package_db()
package_db <- clean_CRAN_db(p_db)
```
The CRAN database we use is from
```{r}
attr(package_db, "timestamp")
```#### Package directives networks
The package directives network can then be built using
```{r cache = TRUE}
package_network <- build_network(package_db)
```
`package_network` can then be interrogated using extractor methods
(see, `?package_by`). For example, my packages can be extracted as follows
```{r}
my_packages <- package_by(package_network, "Ioannis Kosmidis")
my_packages
```
and their sub-network of directives can be summarized in an interactive visualization, a snapshot of which is below
```{r my_pkgs, screenshot.opts = list(delay = 2)}
plot(package_network, package = my_packages, title = TRUE, legend = TRUE)
```We can also compute package summaries and plot "Top-n" lists according to the various summaries
```{r pkg_summaries}
package_summaries <- summary(package_network)
plot(package_summaries, according_to = "n_imported_by", top = 20)
plot(package_summaries, according_to = "page_rank", top = 20)
```#### Collaboration networks
The collaboration network can also be built using a similar call
```{r cache = TRUE}
author_network <- build_network(package_db, perspective = "author")
```
and the extractor functions work exactly as they did for the package directives network. For example, my collaboration network results can be summarized as an interactive visualization, a snapshot of which is below
```{r my_aut, screenshot.opts = list(delay = 2)}
plot(author_network, author = "Ioannis Kosmidis")
```"Top-n" collaborators according to various summaries can again be computed
```{r aut_summaries, warning = FALSE}
author_summaries <- summary(author_network)
plot(author_summaries, according_to = "n_collaborators", top = 20)
plot(author_summaries, according_to = "n_packages", top = 20)
plot(author_summaries, according_to = "page_rank", top = 20)
```Well, the usual suspects...
#### Package dependence trees
Since version 0.2 **cranly** includes functions for constructing and
working with package dependence tree objects. A package's dependence tree shows what else needs to be installed with the package in an empty package library with the package, and hence it can be used to
+ remove unnecessary dependencies that "drag" with them all sorts of other packages
+ identify packages that are heavy for the CRAN mirrors
+ produced some neat visuals for the packageFor example, the dependence tree of the **PlackettLuce** R package I am co-authoring is
```{r dep_tree, screenshot.opts = list(delay = 2)}
PL_dependence_tree <- build_dependence_tree(package_network, "PlackettLuce")
plot(PL_dependence_tree)
```**cranly** also implements a *package dependence index* (see ?summary.cranly_dependence_tree for mathematical details). The closer that is to 0 the "lighter" the package is
```{r}
summary(PL_dependence_tree)
```Check the package vignettes for a more comprehensive tour of the package and for network visualizations on authors with orders of magnitude larger collaboration networks than mine.
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.