Licensing R Packages that Include Others Code

I wanted to include others code in my package, and couldn’t find any good resources.

R
packages
open-science
licensing
Author

Robert M Flight

Published

February 14, 2018

TL;DR

If you include others code in your own R package, list them as contributors with comments about what they contributed, and add a license statement in the file that includes their code.

Motivation

I recently created the knitrProgressBar package. It is a really simple package, that takes the dplyr progress bars and makes it possible for them to write progress to a supplied file connection. The dplyr package itself is licensed under MIT, so I felt fine taking the code directly from dplyr itself. In addition, I didn’t want my package to depend on dplyr, so I wanted that code self-contained in my own package, and I wanted to be able to modify underlying mechanics that might have been more complicated if I had just made a new class of progress bar that inherited from dplyr’s.

I also wanted to be able to release my code on CRAN, not just on GitHub. I knew to accomplish that I would have to have all the license stuff correct. However, I had not seen any guide on how to license a package and give proper attribution in the Authors@R field.

Note that I did ask this question on StackOverflow and ROpenSci forums as well.

Information from CRAN

I should note here, that the CRAN author guidelines do provide a small hint in this regard in the Writing R Extensions guide:

Note that all significant contributors must be included: if you wrote an R wrapper for the work of others included in the src directory, you are not the sole (and maybe not even the main) author.

However, there is not any guidance provided on how these should ideally be listed.

Full Answer

I am the main author and maintainer of the new package, that is easy. The original code is MIT licensed, authored by several persons, and has copyright held by RStudio.

My solution then was to:

  • add the MIT license from dplyr to the file that has the progress bar code
  • add all the authors of dplyr as contributors to my package, with a comment as to why they are listed
  • add RStudio as a copyright holder to my package, with a comment that this only applies to the one file

So the Authors@R line in my DESCRIPTION ended up being:

Authors@R: c(person(given = c("Robert", "M"), family = "Flight", email = "rflight79@gmail.com", role = c("aut", "cre")),
            person("Hadley", "Wickham", role = "ctb", comment = "Author of included dplyr fragments"),
            person("Romain", "Francois", role = "ctb", comment = "Author of included dplyr fragments"),
            person("Lionel", "Henry", role = "ctb", comment = "Author of included dplyr fragments"),
            person("Kirill", "Müller", role = "ctb", comment = "Author of included dplyr fragments"),
            person("RStudio", role = "cph", comment = "Copyright holder of included dplyr fragments"))

Reuse

Citation

BibTeX citation:
@online{mflight2018,
  author = {Robert M Flight},
  title = {Licensing {R} {Packages} That {Include} {Others} {Code}},
  date = {2018-02-14},
  url = {https://rmflight.github.io/posts/2018-02-14-licensing-r-packages-that-include-others-code},
  langid = {en}
}
For attribution, please cite this work as:
Robert M Flight. 2018. “Licensing R Packages That Include Others Code.” February 14, 2018. https://rmflight.github.io/posts/2018-02-14-licensing-r-packages-that-include-others-code.