pkginfo: Tools for Retrieving R Package Information

[This article was first published on Rsquared Academy Blog - Explore Discover Learn, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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    84     13    14

Issues

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

myRepo$get_issues()
## # A tibble: 13 x 4
##    date       number author      title                                          
##    <date>      <int> <chr>       <chr>                                          
##  1 2020-06-06    163 AminHP      "Stepwise selection based on Adjusted R-Square~
##  2 2020-05-05    162 Fernal73    "User must be able to specify different best s~
##  3 2020-05-04    161 Fernal73    "ggplot (or grob) object must be printed when ~
##  4 2020-05-04    160 Fernal73    "Methods returning data.frame of decision crit~
##  5 2020-04-28    159 aravindheb~ "Extracting model data"                        
##  6 2020-04-28    158 Fernal73    "Cannot coerce class ‘\"function\"’ to a data.~
##  7 2020-04-17    157 aravindheb~ "Best subset regression options"               
##  8 2019-12-10    146 sblanco74   "Hi @aravindhebbali"                           
##  9 2019-11-18    138 vasili111   "Linear mixed model support?"                  
## 10 2019-10-04    137 aravindheb~ "Automated report"                             
## 11 2019-10-04    136 aravindheb~ "Import shiny app from xplorerr "              
## 12 2019-06-20    133 aravindheb~ "Cook's distance chart threshold"              
## 13 2018-09-21     92 cccfran     "categorical variable"

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] "Error"
Codecov
myRepo$get_coverage()
## [1] "92.81957"

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    84     13    14

Issues

get_gh_issues("olsrr", "rsquaredacademy")
## # A tibble: 13 x 4
##    date       number author      title                                          
##    <date>      <int> <chr>       <chr>                                          
##  1 2020-06-06    163 AminHP      "Stepwise selection based on Adjusted R-Square~
##  2 2020-05-05    162 Fernal73    "User must be able to specify different best s~
##  3 2020-05-04    161 Fernal73    "ggplot (or grob) object must be printed when ~
##  4 2020-05-04    160 Fernal73    "Methods returning data.frame of decision crit~
##  5 2020-04-28    159 aravindheb~ "Extracting model data"                        
##  6 2020-04-28    158 Fernal73    "Cannot coerce class ‘\"function\"’ to a data.~
##  7 2020-04-17    157 aravindheb~ "Best subset regression options"               
##  8 2019-12-10    146 sblanco74   "Hi @aravindhebbali"                           
##  9 2019-11-18    138 vasili111   "Linear mixed model support?"                  
## 10 2019-10-04    137 aravindheb~ "Automated report"                             
## 11 2019-10-04    136 aravindheb~ "Import shiny app from xplorerr "              
## 12 2019-06-20    133 aravindheb~ "Cook's distance chart threshold"              
## 13 2018-09-21     92 cccfran     "categorical variable"

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-deb~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  2 linux-x86_64-deb~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  3 linux-x86_64-fed~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  4 linux-x86_64-fed~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  5 windows-ix86+x86~ devel  OK     https://www.R-project.org/nosvn/R.check/r-de~
##  6 linux-x86_64      patch~ OK     https://www.R-project.org/nosvn/R.check/r-pa~
##  7 solaris-x86       patch~ OK     https://www.R-project.org/nosvn/R.check/r-pa~
##  8 linux-x86_64      relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
##  9 osx-x86_64        relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
## 10 windows-ix86+x86~ relea~ OK     https://www.R-project.org/nosvn/R.check/r-re~
## 11 osx-x86_64        oldrel OK     https://www.R-project.org/nosvn/R.check/r-ol~
## 12 windows-ix86+x86~ oldrel OK     https://www.R-project.org/nosvn/R.check/r-ol~

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] "Error"

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] "92.81957"

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 2020-06-09 Combining 2 data fra~ Les      FALSE       22 https://stackoverfl~
##  2 2020-06-10 Summarizing one way,~ David T  FALSE       11 https://stackoverfl~
##  3 2020-06-10 Identifying and modi~ Parselt~ TRUE        17 https://stackoverfl~
##  4 2020-06-10 R: How do I append d~ Gordon ~ FALSE       14 https://stackoverfl~
##  5 2020-06-10 customising title of~ smicaela FALSE       10 https://stackoverfl~
##  6 2020-06-10 Aggregate rows withi~ Christo~ FALSE       10 https://stackoverfl~
##  7 2020-06-10 %within% in case_whe~ Rasmus   FALSE       22 https://stackoverfl~
##  8 2020-06-10 R/dplyr: How do I in~ questio~ FALSE       20 https://stackoverfl~
##  9 2020-06-10 Filter rows of one c~ mvanaman FALSE       12 https://stackoverfl~
## 10 2020-06-10 Groupby and keep onl~ chippyc~ FALSE       24 https://stackoverfl~
## # ... 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 .

To leave a comment for the author, please follow the link and comment on their blog: Rsquared Academy Blog - Explore Discover Learn.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)