In a previous post, I showed a very simple example of using the R function tools::CRAN_package_db() to analyze information about CRAN packages. CRAN_package_db() extracts the metadata CRAN stores on all of its 12,000 plus packages and arranges it into a “database”, actually a complicated data frame in which some columns have vectors or lists as entries.
It’s simple to run the function and it doesn’t take very long on my Mac Book Air.
p_db = 2.15.0), xtable, pbapply
## 2 abbyyR 0.5.4 R (__= 3.2.0)
## 3 abc 2.1 R (__= 2.10), abc.data, nnet, quantreg, MASS, locfit
## 4 abc.data 1.0 R (__= 2.10)
## 5 ABC.RAP 0.9.0 R (__= 3.1.0)
## 6 ABCanalysis 1.2.1 R (__= 2.10)
## 7 abcdeFBA 0.4 Rglpk,rgl,corrplot,lattice,R (__= 2.10)
## 8 ABCoptim 0.15.0 ## 9 ABCp2 1.2 MASS
## 10 abcrf 1.7 R(__= 3.1)
## Imports
## 1 ## 2 httr, XML, curl, readr, plyr, progress
## 3 ## 4 ## 5 graphics, stats, utils
## 6 plotrix
## 7 ## 8 Rcpp, graphics, stats, utils
## 9 ## 10 readr, MASS, matrixStats, ranger, parallel, stringr, Rcpp (__=\n0.11.2)
So, having spent a little time leaning how vexing working with this data can be, I was delighted when I discovered Ioannis Kosmidis’ cranly package during my March “Top 40” review. cranly is a very impressive package, built along tidy principles, that is helpful for learning about individual packages, analyzing the structure of package and author relationships, and searching for packages.
library(cranly)
library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 2.2.1 ✔ purrr 0.2.4
## ✔ tibble 1.4.2 ✔ dplyr 0.7.5
## ✔ tidyr 0.8.1 ✔ stringr 1.3.1
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ─────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
The first really impressive feature is a “one button” clean function that does an amazing job of getting the data in shape to work with. In my preliminary work, I struggled just to get the author data clean. In the approach that I took, getting rid of text like [aut, cre] to get a count of authors took more regular expression work than I wanted to deal with. But clean_CRAN_db does a good job of cleaning up the whole database. Note that the helper function clean_up_author has a considerable number of hard-coded text strings that must have taken hours to get right.
package_db