I am navigating licensing, and this is very confusing.

I produced a lot of R code to analyze data for a research article that will be published on a peer-reviewed journal.

Reading here License for R scripts, I can understand that I would need to pay attention to the license type of the packages I used before choosing a license for my code.

Now, I have a few issues as the R packages I used have all different types of licenses.

For example:

> packageDescription("ggplot2", fields="License")
[1] "MIT + file LICENSE"
> packageDescription("glmmTMB", fields="License")
[1] "AGPL-3"
> packageDescription("RColorBrewer", fields="License")
[1] "Apache License 2.0"

The list is quite long and I also have "GPL (>= 2.0)" and "GPL-3" . So, I am now very confused on how should I license my code, as I am aware that not in all cases the different licenses are compatible with each other. For example, GPL v2 is not always compliant with GPL v3 and vice-versa.

Is there a way I can understand this and avoid of making mistakes?


Sadly I also have used packages with GPL V2.

1 Answer 1


Let's look at the licenses you list:

  • AGPL-3
  • MIT
  • Apache v2
  • GPL v2+

MIT is a very permissive license and can be combined with either of the other three.

Apache v2 is a permissive license, but due to some patent indemnification clauses it is incompatible with GPL v2.

The AGPL v3 is like the GPLv3 but with the further requirement that its terms also apply when users interact with the software over a network interface.

Thus from the mentioned licenses, your only choice to distribute software with libraries using all mentioned licenses, is the AGPL v3.

Now that this is settled, you can use the list of licenses compatible with the (A)GPL v3 as provided by the FSF.

The most noteworthy license you can NOT combine your work with (and still legally distribute it), will be libraries which are under GPL v2 only (thus without the option to choose a newer version of the GPL). You will be able to include any library under any of the usual permissive licenses like MIT, BSD, etc.

May sound like a picky detail: you are not necessarily required to license your code under the AGPL v3 under these circumstances. But you may only distribute the whole software along with all the required libraries under AGPL v3 (as long as one of the required libraries is under AGPL v3).

This said: AGPL v3 is not a bad license for science, rather on the contrary: it requires attribution as any open source license, and it requires users to share their code modifications when they distribute it, and also share it when they offer a service with it, e.g. a website which interactively calculates stuff.

Further: if you do not distribute any complete software, you basically can choose any license - but the "wrong" choice might make it un-distributable for everyone else, too. As such my recommendation remains to always to use a license which allows distribution with all libraries used included. In your case that would be AGPL v3.

  • Great, thank you very much for the answer. Sadly, I also have GPL-2. As far as I have been reading so far there is no way to combine all license of all the packages I have been using. So, does this mean that I cannot make my code publicly available?
    – efrem
    Commented Sep 14, 2023 at 15:09
  • Just to clarify, I am not packaging a library or software. This is just the code I used that I want to make public to foster transparency and reproducibility.
    – efrem
    Commented Sep 14, 2023 at 15:14
  • @efrem It doesn't sound like you need a license for those packages at all then. The downstream users of your code can install those packages independently though CRAN (as is typical). Commented Sep 14, 2023 at 17:45
  • 2
    @efrem I'd recommend to check in the package text itself whether the package that is tagged "GPL-2" is really "GPL-2" as in "GPL 2 only" or whether the license text in that package actually includes a permission "(or at your option, any later verson)." If it says that it can be used with a later GPL version, then it's probably a tagging error and it is supposed to say "GPL>=2.0".
    – Brandin
    Commented Sep 15, 2023 at 7:47
  • 1
    Thank you all very much for your comments, this helped me a lot. So basically if I understand this correctly, as I do not have a software/package which I indent to be distributed, I do not necessarily need to license my code. If I want to license my code, I can choose any license as again this is simply code I used for my work/paper and not a distributed packages/software. This means that I do not need to take care that the license I choose will be compatible with the licenses of the packages I used. Did I get your comments right? Sorry, this is a bit confusing for me. Thank you
    – efrem
    Commented Sep 18, 2023 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.