There are a wealth of excellent resources for R users on creating and maintaining R packages, which remain the best way to share your code within your organisation or the larger community. However, almost all of these resources tend to focus on open-source packages, tools, and workflows. As a result of this, they tend to skim over more corporate issues like copyright assignment.

Yet many R users are working on their code in proprietary environments, creating packages for internal use by their company. That code is closed source, with the copyright belonging to their organisation. If you fall into this category, how should you communicate that in your R package? This post is intended to provide a very clear answer to that question.

It turns out that R has excellent support for embedding copyright information in the metadata of the package itself. This makes it easy to precisely communicate both open- and closed-source ownership in a few well-defined places: your DESCRIPTION and LICENSE files.

The DESCRIPTION File

It is very likely that if you are writing R packages for your employer, they are the ultimate copyright owner of the software. Fortunately it’s very easy to lay out this fact in your DESCRIPTION file – there is a special copyright holder role ( cph ) that can be used in the Authors fields. For example, suppose that I worked for Widgets Incorporated. In that case, my DESCRIPTION file would contain something like the following:

Authors@R: c( person("Aaron", "Jacobs", role = c("cre", "aut")), person("Widgets Incorporated", role = "cph") )

This is not quite the end of the story, because R also requires that you to lay out what open-source license your code is available under in the License field, or use the special value file LICENSE to point users to a file explaining it. Since your code is not open-source, your DESCRIPTION file must take this route and contain the following:

License: file LICENSE

But this just punts on the issue – what do you put in that LICENSE file?

The LICENSE File

Hadley Wickham’s highly influential R Packages book makes the following suggestion for the contents of a proprietary LICENSE file:

Proprietary Do not distribute outside of Widgets Incorporated.

In my view, this is a mistake. Why? Because this file says absolutely nothing about copyright. It bears no resemblance to a valid software license; notably, it does not detail any of the rights or permissions granted to those in possession of the source code.

But wait, you say, my company doesn’t want to grant any rights or permissions! If this is the case – and likely it is – your LICENSE file should contain a familiar legal phrase: “All rights reserved”. In full:

Copyright 2019 Widgets Incorporated. All rights reserved.

This is a true proprietary software license.

Relicensing

For most closed source code, this is the end of the copyright story. But some initially-internal packages are later released under an open source license, and you might be curious as to how you should go about doing this.

Fortunately the answer is quite simple if you’ve got things set up as I outlined above: all you have to do is change the license. If you are using one of the open-source licenses understood by R itself, you can delete the LICENSE file and change the License field in your DESCRIPTION file. If you are using a more uncommon license, just replace the content of the LICENSE file in its entirety with the text of that license.

(You can see examples of this on GitHub in the commit history of the internal projects an employer permitted me to open-source: here and here.)

It is important to note what you should not change here, namely the copyright role ( cph ) for your employer in the DESCRIPTION file. Open-sourcing a package does not transfer copyright to you or anyone else – that is a wholly separate process.

TL;DR

To sum up, put this in your DESCRIPTION file:

Authors@R: c( person("<My>", "<Name>", role = c("cre", "aut")), person("<My Company>", role = "cph") ) License: file LICENSE

And this in a LICENSE file:

Copyright 2019 <My Company>. All rights reserved.

And that’s it.