Proper identification of individuals is crucial for acknowledging and
studying their scientific work, be it journal articles or pieces of
software. In this tech note, one year after CRAN started supporting
ORCIDs, we shall explain why and how to use unique author identifiers in
DESCRIPTION files.
Why use ORCIDs on CRAN?
When analyzing the authorship of CRAN packages, one can look at authors’
names and email addresses. Names can be written with and without quotes,
email addresses change, which makes it all tricky as noted by David
Smith when he looked for the most prolific CRAN
authors
(notice our very own Scott Chamberlain and Jeroen Ooms in that
scoreboard by the way?). Besides, several people can have the same name!
So all in all, using an unique ID per author makes sense. That’s
something offered for the academic world and beyond by
ORCID, ORCID meaning “Open
Researcher and Contributor ID”. Anyone can set up an ORCID account for
free and link it up to the rest of their online persona, as well as to
their employment and works. When the authors of a scientific paper give
their ORCID ID to the publisher, these can be included in the html and
PDF versions of a
paper.
Note that there’s no, say, Keybase verification for
ORCIDs, and often the
input of an ORCID ID for a paper is declarative as well. Read more about
ORCID here.
About one year ago, CRAN added support for
ORCID in
DESCRIPTION files by a minimally invasive
hack. One
can add the ORCID ID of an author as a comment field in person(),
see e.g. Carl Boettiger’s ID in codemetar
DESCRIPTION,
and one gets a nice little green bubble near their name on CRAN, see
e.g. codemetar CRAN
page.
The advantages of using ORCID IDs in DESCRIPTION are:
Unique identifiers for free! Sure, there’s no verification so
someone could use your identity, but at least, it should help
assigning your own work to you.
Clickable name on CRAN pages, METACRAN pages and pkgdown
websites! E.g. when clicking on Carl’s green bubble on codemetar
CRAN page, one gets to his ORCID
profile including a link to
his personal website. See also codemetar METACRAN
page and codemetar pkgdown
website.
Even for non academics, making one’s online persona more accessible from
a CRAN DESCRIPTION can’t hurt.
How to manipulate ORCIDs in DESCRIPTION?
So, how does one add add and interact with ORCID in DESCRIPTION? Well,
thankfully, the current dev version of the RStudio desc
package by Gábor
Csárdi has some direct support of
ORCIDs! Gábor too is well ranked in the scoreboard mentioned
earlier!
remotes::install_github(&quot;r-lib/desc&quot;)
Search authors by ORCID
desc offers many functions for manipulating authors: adding or
deleting them or their roles. Now you can perform these operations using
ORCID to identify authors to be modified. E.g. if you want to add a role
to an existing author, say Carl who worked hard enough to earn the “aut”
role, you’d run
desc::desc_add_role(role = &quot;aut&quot;,
orcid = &quot;0000-0002-1642-628X&quot;)
Obviously this very example above has probably little real-life
applicability, but you could imagine manipulating DESCRIPTION files en
masse using a table of ORCIDs and new roles.
Add ORCID to authors of a package
The new add_orcid() method and desc_add_orcid() functions make it
possible to add ORCID IDs to authors directly instead of via the
comment argument. So you could write some script
desc::desc_add_orcid(&quot;0000-0002-2815-0399&quot;,
given = &quot;Maëlle&quot;,
family = &quot;Salmon&quot;)
and run it inside all your local package folders to add your ORCID. It
will add this ORCID ID to the author whose given name is “Maëlle” and
whose family name is “Salmon”. If you only write
desc::desc_add_orcid(&quot;0000-0002-2815-0399&quot;,
given = &quot;Maëlle&quot;)
and there are two Maëlle’s, the function will error and you’ll need to
run it with more specific arguments.
Add all of your identity at once!
The coolest feature of desc ORCID support might be that
desc::desc_add_me() will now use the ORCID of the environment variable
ORCID_ID if you created it. Hence, once per machine it’d now be
recommended to
install the whoami package necessary for desc::desc_add_me() to
work. install.packages(&quot;whoami&quot;).
create an environment variable ORCID_ID, editing .Renviron by
calling e.g. usethis::edit_r_environ(). Here’s how the
corresponding .Renviron line looks for me:
ORCID_ID=&quot;0000-0002-2815-0399&quot;
desc::desc_add_me() looks for your name and email addresses in your
existing configuration (git configuration, GitHub profile), see the
whoami package docs. So say you’ve
just been told to add yourself as contributor of a package you’ve
improved: inside the package directory, you’d just need to run
desc::desc_add_me() and voilà ! No risk to wrongly copy-paste your
ORCID.
As a conclusion of this section, not only are ORCIDs useful, but they’re
getting citizen status in the world of as-automatic-as-possible package
development. Now, we shall see how one could use ORCIDs inside R to
gather information about package authors.
How to study CRAN authors via their ORCID
As mentioned earlier, rOpenSci’s Scott Chamberlain is the most prolific
CRAN package
maintainer,
so perhaps unsurprisingly, he maintains a package interacting with
ORCID’s API, rorcid!
The API requires authentication so the first step after installing the
package is to run:
rorcid::orcid_auth()
and to save the resulting token as an ORCID_TOKEN environment variable
in .Renviron (again, usethis::edit_r_environ() can help with that).
Authentication warrants your having an ORCID account, so if you haven’t
one yet, register via this link.
Then, we’ll query all comment’s of Authors@R of CRAN packages. Some
CRAN packages use the Author field instead, which is not recommended
and doesn’t allow using comment.
Side-note, in general, how would one analyze stuff over the whole CRAN
collection?
Some information can be found in tools::CRAN_package_db() as seen
in this recent tech
note.
There’s an official read-only mirror of each all CRAN packages on
GitHub thanks to METACRAN.
METACRAN serves a CRAN package
database, wrapped by an R
package of course.
One could try setting up a local CRAN mirror.
Thanks to Gábor, who maintains METACRAN, for patiently answering my
questions about meta-CRAN things. If we were after the comments section
of just a few packages, we could query METACRAN database like so:
url