A while ago we
onboarded an
exciting package, codemetar
by Carl Boettiger. codemetar is an R specific
information collector and parser for the CodeMeta
project. In particular, codemetar can
digest metadata about an R package in order to fill the terms
recognized by CodeMeta. This means
extracting information from DESCRIPTION but also from e.g. continuous
integration[1] badges in the README! In this note, we’ll take advantage
of codemetar::extract_badges function to explore the diversity of
badges worn by the READMEs of CRAN packages.
Why codemetar::extract_badges, and how
CodeMeta recognized terms include information we’ve been getting from
badges:
“contIntegration”, URLs to continuous integration services such as
Travis, Appveyor, Codecov;
“review”, information about review of the software if there was one.
codemetar recognizes information from the peer-review badge we add
to the README of onboarded packages thanks to work by Karthik
Ram.
The list might get longer, so instead of using regular expressions on
the README text, we extract and memoize[2] all badges at once to a
data.frame that we then query. The badges extraction is based on (in the
dev branch of codemetar):
conversion to XML using commonmark (see my recent tech
note) which works well for the
Markdown badges e.g.
[![Travis-CI Build Status](https://travis-ci.org/ropensci/codemetar.svg?branch=master)](https://travis-ci.org/ropensci/codemetar).
extraction and parsing on the first HTML table there is if there’s
any, which is necessary for badges in table, which we’ve been
discussing for our
guidelines.
Note that the CRAN version of codemetar already features
extract_badges, but with a badges table creation based on regular
expressions only. Here is codemetar::extract_badges in action on the
README of the drake package:
library(&quot;magrittr&quot;)
codemetar::extract_badges(&quot;https://raw.githubusercontent.com/ropensci/drake/master/README.md&quot;) %__%
knitr::kable()
text
link
image_link
ropensci_footer
https://ropensci.org
http://ropensci.org/public_images/github_footer.png
JOSS
https://doi.org/10.21105/joss.00550
http://joss.theoj.org/papers/10.21105/joss.00550/status.svg
Licence
https://www.gnu.org/licenses/gpl-3.0.en.html
https://img.shields.io/badge/licence-GPL--3-blue.svg
AppVeyor
https://ci.appveyor.com/project/ropensci/drake
https://ci.appveyor.com/api/projects/status/4ypc9xnmqt70j94e?svg=true&amp;branch=master
rOpenSci
https://github.com/ropensci/onboarding/issues/156
https://badges.ropensci.org/156_status.svg
minimal R version
https://cran.r-project.org/
https://img.shields.io/badge/R%3E%3D-3.3.0-blue.svg
Travis
https://travis-ci.org/ropensci/drake
https://travis-ci.org/ropensci/drake.svg?branch=master
CRAN
http://cran.r-project.org/package=drake
http://www.r-pkg.org/badges/version/drake
downloads
http://cran.rstudio.com/package=drake
http://cranlogs.r-pkg.org/badges/drake
Codecov
https://codecov.io/github/ropensci/drake?branch=master
https://codecov.io/github/ropensci/drake/coverage.svg?branch=master
Zenodo
https://zenodo.org/badge/latestdoi/82609103
https://zenodo.org/badge/82609103.svg
Project Status: Active â€“ The project has reached a stable, usable state and is being actively developed.
http://www.repostatus.org/#active
http://www.repostatus.org/badges/latest/active.svg
Quite handy for our metadata collection!
Read the source for extract_badges
here
and see how it’s used in this
script.
You can also compare codemetar’s
README
with its
codemeta.json
e.g. the lines for
“contIntegration”.
Now since, codemetar::extract_badges exports a nice data.frame for any
README with badges, and is exported, it’d be too bad not to use it to
gain insights from many, many READMEs!
Extract badges from CRAN packages
In this exploration we shall concentrate on CRAN packages that indicate
a GitHub repo link under the URL field of DESCRIPTION. By the way, if
you don’t indicate such links in DESCRIPTION of your package yet, you
can (and should) run
usethis::use_github_links.
Get links to GitHub repos from CRAN information
I reckon that I could have also used BugReports like Steven M Mortimer
did in his great analysis of CRAN downloads and GitHub
stars. I
am unsure of how one can get the link to and the content of the README
of packages that don’t Rbuildignore their README, such as
codemetar
(see under Material). The imperfect sample I collected will do for this
note.
Here’s how I got all the repo owners and names:
cran_db