Rating R Packages

2016-08-13

The new rOpenSci package packagemetrics is a new ‘meta’ package for R with info on packages: dependencies, how long issues take to be resolved, how many watchers on GitHub, and more. Let’s take a look at a few packages I use and some of my own. Install:

install.packages("formattable")
devtools::install_github("ropenscilabs/packagemetrics")

Then load the packages we’re going to use (I liked the table they have in their README, so I thought I’d keep with that style):

library(formattable)
library(packagemetrics)
library(dplyr)

Next, let’s get the packages I’m interested in and make our nice table:

packages <- list("dplyr", "tidyr", "tidyRSS",
              "congressbr", "rstan", "rjags",
              "electionsBR", "tmap")


pd <- purrr::map(packages, combine_metrics) %>%
  data.table::rbindlist() %>%
  select(package, published, dl_last_month, stars, forks,
         last_commit, last_issue_closed,
         depends_count, watchers) %>%
  mutate(last_commit = round(last_commit, 1),
         last_issue_closed = round(last_issue_closed, 1))

pd[is.na(pd)] <- ""

formattable(pd, list(
    package = formatter("span",
                      style = x ~ style(font.weight = "bold")),
    contributors = color_tile("white","#1CC2E3"),
    depends_count = color_tile("white", "#1CC2E3"),
    reverse_count = color_tile("white", "#1CC2E3"),
    tidyverse_happy = formatter("span",
                                style = x ~ style(color = ifelse(x, "purple","white")),
                                x ~ icontext(ifelse(x, "glass","glass"))),
    vignette = formatter("span",
                         style = x ~ style(color = ifelse(x, "green","white")),
                         x ~ icontext(ifelse(x, "ok","ok"))),
    has_tests =  formatter("span",
                           style = x ~ style(color = ifelse(x, "green","red")),
                           x ~ icontext(ifelse(x, "ok","remove"))),
    dl_last_month = color_bar("#56A33E"),
    forks = color_tile("white", "#56A33E"),
    stars = color_tile("white", "#56A33E"),
    last_commit = color_tile("#F06B13","white", na.rm=T),
    last_issue_closed = color_tile("#F06B13","white", na.rm=T)
  ))
package published dl_last_month stars forks last_commit last_issue_closed depends_count watchers
dplyr 2019-02-15 759338 2864 1049 0 0 1 258
tidyr 2019-03-01 477218 716 282 0.1 0 1 73
tidyRSS 2019-03-05 1215 29 10 0.9 0.6 1 5
congressbr 2019-02-17 498 1
rstan 2018-11-07 33293 541 179 0 3 79
rjags 2018-10-19 15799 2
electionsBR 2017-06-06 398 32 9 2 1 9
tmap 2019-01-05 18297 312 58 0.2 0.2 2 26

Nice table. It’s not perfect – maybe they still have some bugs to work out – congressbr is missing watchers and stars, but this is a nice little package. Still, there are so many packages out there that I still use them based on cool examples I see, either on blogs, twitter, or in academic papers. I’ve never much used the CRAN Task Views and I doubt I’ll use packagemetrics much, but it’s interesting for those who get their R this way.