5 min read

pkginfo: Tools for Retrieving R Package Information

Motivation

There are several wonderful tools for retrieving information about R packages, some of which are listed below:

We have used some or all of these to track/monitor our own R packages available on CRAN. Over time, we wanted to have a single interface which would retrieve information from different places including:

And below is a demo of what we came up with…

The above shiny app can be launched with:

pkginfo::pkginfo_dashboard()

Introduction

pkginfo will allow you to retrieve information from multiple places. The shiny app is especially useful if you are looking for information about multiple R packages. pkginfo provides two APIs, one is object oriented, the other one is procedural, and in this post, we will show you how to use them.

Installation

You can install the development version from GitHub with:

devtools::install_github("rsquaredacademy/pkginfo")

course ad


Object Oriented API

The object oriented API uses R6 classes.

library(pkginfo)

GitHub

Creating a new GitHubRepo object

myRepo <- GitHubRepo$new("olsrr", "rsquaredacademy")

Stars, Forks & Issues

get_stats() will report the number of stars, forks and open issues.

myRepo$get_stats()
## # A tibble: 1 x 3
##   stars issues forks
##   <int>  <int> <int>
## 1    77     26    11

Issues

get_issues() will report the date, number, author and title of all the open issues.

myRepo$get_issues()
## # A tibble: 26 x 4
##    date       number author        title                                   
##    <date>      <int> <chr>         <chr>                                   
##  1 2019-06-20    133 aravindhebba~ Cook's distance chart threshold         
##  2 2018-12-27    129 aravindhebba~ Bonferroni outlier test                 
##  3 2018-12-24    126 aravindhebba~ Heteroskedasticity corrected covariance~
##  4 2018-12-24    125 aravindhebba~ Test linear hypothesis                  
##  5 2018-12-24    124 aravindhebba~ Ceres plot                              
##  6 2018-12-22    123 aravindhebba~ Power transformations                   
##  7 2018-12-22    122 aravindhebba~ Box Tidwell transformation              
##  8 2018-12-22    121 aravindhebba~ Box Cox transformation                  
##  9 2018-12-21    120 aravindhebba~ Wald test                               
## 10 2018-12-21    119 aravindhebba~ Reset test                              
## # ... with 16 more rows

Branches

get_branches() will report the name of the branches.

myRepo$get_branches()
## # A tibble: 2 x 1
##   branches
##   <chr>   
## 1 develop 
## 2 master

Build Status & Code Coverage

The build status is reported from Travis CI and Appveyor while code coverage is reported from Codecov

Travis CI
myRepo$get_travis_status()
## [1] "Failure"
Codecov
myRepo$get_coverage()
## [1] "82.83485"

youtube ad


Procedural API

GitHub

To use the procedural API for retrieving GitHub information, you need to provide the following inputs:

  • package/repo name
  • GitHUb user/organization name (optional)

If you do not know the GitHub user/org name, leave it empty. pkginfo will look for the user/org name in the URLS available on the CRAN page of the package.

Stars, Forks & Issues

get_gh_stats("olsrr", "rsquaredacademy")
## # A tibble: 1 x 3
##   stars issues forks
##   <int>  <int> <int>
## 1    77     26    11

Issues

get_gh_issues("olsrr", "rsquaredacademy")
## # A tibble: 26 x 4
##    date       number author        title                                   
##    <date>      <int> <chr>         <chr>                                   
##  1 2019-06-20    133 aravindhebba~ Cook's distance chart threshold         
##  2 2018-12-27    129 aravindhebba~ Bonferroni outlier test                 
##  3 2018-12-24    126 aravindhebba~ Heteroskedasticity corrected covariance~
##  4 2018-12-24    125 aravindhebba~ Test linear hypothesis                  
##  5 2018-12-24    124 aravindhebba~ Ceres plot                              
##  6 2018-12-22    123 aravindhebba~ Power transformations                   
##  7 2018-12-22    122 aravindhebba~ Box Tidwell transformation              
##  8 2018-12-22    121 aravindhebba~ Box Cox transformation                  
##  9 2018-12-21    120 aravindhebba~ Wald test                               
## 10 2018-12-21    119 aravindhebba~ Reset test                              
## # ... with 16 more rows

packages ad


CRAN Check Results

The CRAN check results is reported using the cchecksapi API.

get_pkg_cran_check_results("olsrr")
## # A tibble: 12 x 4
##    os               r      status url                                      
##    <chr>            <chr>  <chr>  <chr>                                    
##  1 linux-x86_64-de~ devel  OK     https://www.R-project.org/nosvn/R.check/~
##  2 linux-x86_64-de~ devel  OK     https://www.R-project.org/nosvn/R.check/~
##  3 linux-x86_64-fe~ devel  OK     https://www.R-project.org/nosvn/R.check/~
##  4 linux-x86_64-fe~ devel  OK     https://www.R-project.org/nosvn/R.check/~
##  5 windows-ix86+x8~ devel  OK     https://www.R-project.org/nosvn/R.check/~
##  6 linux-x86_64     patch~ OK     https://www.R-project.org/nosvn/R.check/~
##  7 solaris-x86      patch~ OK     https://www.R-project.org/nosvn/R.check/~
##  8 linux-x86_64     relea~ OK     https://www.R-project.org/nosvn/R.check/~
##  9 windows-ix86+x8~ relea~ OK     https://www.R-project.org/nosvn/R.check/~
## 10 osx-x86_64       relea~ OK     https://www.R-project.org/nosvn/R.check/~
## 11 windows-ix86+x8~ oldrel OK     https://www.R-project.org/nosvn/R.check/~
## 12 osx-x86_64       oldrel OK     https://www.R-project.org/nosvn/R.check/~

Build Status

You can check the build status of a package from both Travis CI and Appveyor.

Travis CI

get_status_travis("olsrr", "rsquaredacademy")
## [1] "Failure"

Appveyor

get_status_appveyor("olsrr", "rsquaredacademy")
## [1] "failed"

Code Coverage

Report code coverage for the package from the coverage service Codecov. We hope to add coverage from Coveralls in the near future.

get_code_coverage("olsrr", "rsquaredacademy")
## [1] "82.83485"

Stack Overflow

Questions tagged with the package name will be displayed from Stack Overflow.

get_so_questions("dplyr")
## # A tibble: 30 x 6
##    date       title               owner   answered views link              
##    <date>     <chr>               <chr>   <lgl>    <int> <chr>             
##  1 2019-07-22 subset data based ~ Amer    TRUE        29 https://stackover~
##  2 2019-07-21 ID variable change~ user88~ FALSE       21 https://stackover~
##  3 2019-07-18 How to group by an~ kdkirc~ FALSE       26 https://stackover~
##  4 2019-07-21 How to do countifs~ frida ~ TRUE        30 https://stackover~
##  5 2019-07-21 sample_frac functi~ squeez~ FALSE       30 https://stackover~
##  6 2019-07-21 Using clusrank by ~ Jason ~ TRUE        29 https://stackover~
##  7 2019-07-21 Fastest way to exp~ JaimieC FALSE       32 https://stackover~
##  8 2019-07-21 What does the !! o~ maleta  FALSE       34 https://stackover~
##  9 2019-07-21 Create an event in~ Marco   TRUE        37 https://stackover~
## 10 2019-07-21 lubridate with_tz ~ hjw     FALSE       23 https://stackover~
## # ... with 20 more rows

To Do..

In the near future, pkginfo will retrieve information:

  • about packages that are available on GitHub/GitLab but not on CRAN
  • packages that are available on GitLab
  • about code coverage from Coveralls
  • about Twitter mentions

We did not have any specific end user in mind while developing but believe it will be more useful to package developers/maintainers. Suggestions/feedbacks and pull requests are always welcome.

If you see mistakes or want to suggest changes, please create an issue on the source repository or reach out to us at .