65

Intro: R is a open-source software tool for statistical analyses and graphics, which is heavily used in different science disciplines and which is becoming more and more popular (although it is already quite popular in many areas). In addition to the base version, people from all over the place develop so-called packages, upload them, for example, to CRAN, where they can be freely downloaded to use.

Q: I am writing a manuscript for a peer-reviewed psychology journal and used a lot of R packages in my work. Of course, I want to and will cite R itself and the packages that I relied on heavily (e.g., to simulate or analyze data). However, I have also some packages, of which I used only a single, little function. For example, I used the odd function from the gtools package to determine whether an integer is odd or even. As far as I can see, the function is only a single line long, and I could have written it myself (but I didn't!). On the one hand, I want to give credit to these developers, on the other hand I don't want to blow up my reference list and confuse readers. So the question is, should I cite every single R package I used?

BTW: Note that R has the nice function citation("some package") to access citation information provided by the package authors; see also citation() to cite R itself.

4
  • 10
    Here is kind of a similar question: tex.stackexchange.com/questions/156189/…. I think the bottom line is that you should cite all packages that affected your results (for reproducibility), but you do not need to cite the ones you used for plotting, table making, etc. Acknowledgments are the correct place for that kind of packages.
    – Mikko
    Aug 28, 2014 at 12:52
  • 16
    toLatex(sessionInfo()) gives you all you need for people to be able to replicate your environment.
    – James
    Aug 28, 2014 at 12:59
  • 5
    more important than citing is sharing the data and code.
    – phonixor
    Aug 28, 2014 at 14:52
  • 5
    Citing R and its packages (in the light of the answers below) would support the development of such great, yet free of charge, open source tools.
    – Orion
    Feb 14, 2015 at 18:11

5 Answers 5

38

Overall, I would suggest you err on the side of rather citing too many packages (with version numbers, please!), although odd quite probably is a borderline case. I'd rationalize this tendency as a bit of balance for all the people who use packages extensively but do not cite them.

In general, I would certainly cite anything that saved me a non-trivial amount of own work (as in, "I could have done this myself, but it would likely have cost me half a day").

The length of your literature list should not really be a concern in the days of PDF publishing. And "we used R [3], packages foo [4] and bar [5] as well as multiple helper functions [6-10]" should not be too confusing to your readers.

3
  • 4
    You should cite everything you use. Maybe many won't do it because they just use too many packages. This shouldn't hinder you from citing. So here's how to cite multiple packages at once: blogs.ethz.ch/mylifesciencejourney/2017/07/14/…
    – walls
    Jul 14, 2017 at 12:12
  • 3
    Unfortunately, there is a practical limit to this strategy in some cases: at least in my case, there are still a lot of page limits around, which severely limit the number of references one wants to give in an article...
    – Eike P.
    May 9, 2020 at 13:58
  • @walls: That link do not work. Aug 28, 2022 at 5:27
45

YES.

There are lots of reasons to and no reasons not to (unless you're under some kind of strange space/ink constraint).

Here is an important and under-appreciated reason why:

Most of the people who make the kinds of R packages, in fact the people who made R itself, are other academics. Meaning: They didn't get paid specifically for the time they spent making lme4, ggplot2, stargazer etc. Software development is very unappreciated in academia. Imagine spending a lot of time writing and maintaining a package that is used by thousands of people in your field and then being asked by a tenure/promotion committee why you didn't write more papers or do more experiments. It's very difficult to get someone who isn't a user (or even a software-minded person) to properly appreciate the time and skill involved in making good software.

The only way to convince university systems and leaders that the work you spent writing that software is to show them in a way they understand, that means citations. They're not going to care about your Stack Exchange reputation or how much juice you've got on GitHub, they need something Scopus can compute and they can itemize and count.

Much of the workings of academia is based on beans. Much of the effort at universities is dedicated to counting and managing those beans. How many students are in your program, how many grants are awarded, how many Ph.D. defend, and how many papers are published and cited are all very important beans which decide who gets resources. It would be sad indeed if someone who wrote a useful R package didn't get the credit they're due and thus be allowed to make more wonderful tools. Imagine if Hadley hadn't started working for R-Studio, he might be standing in front of some committee someday asking him why he spent so much time writing "software" instead of "papers," or trying to explain why he can't take on a third course this semester because the dept chair doesn't understand that writing software is something that actually takes real time.

Also consider this: Most scientific papers are cited fewer than 10 times, if ever. A reasonably useful R package is likely to impact many more people than any "real" publication, but that person gets no credit if you don't cite it.

1
  • 2
    I very much agree with the importance of citation to generate measurable numbers for science administration. I develop packages and yes, it is important to be able to justify the effort - the more so if your institute is still rather reluctant about open source (not to speak of open data...). In my field pointing out how many people cite the package is an important and easy to gather number. This is IMHO even more important for small niche packages than, say, for ggplot2. (Nevertheless I also cite the packages I use "only" for graphical display etc). Apr 6, 2016 at 9:29
19

Absolutely! Citations are free, and they are a blessing to the creators of those packages. Unless you're held to a strict page limit, there's no reason not to have a "methods" section in which you list all of the packages you used. It can be a single sentence. If you want to give pride of place to a few key packages that your work relied on, then give them a sentence each, but don't snub the others. Some day, you'll be happy when others cite your work.

13

There's no definite answer to this, but here's what I do.

  1. I cite R itself and the packages I need to perform the actual analysis I report in my paper. I do not cite packages I consider to provide various tools (graphic tools, mathematical tools, etc.). The line between these can be difficult to draw sometimes, of course.
  2. Always, always make your data and your code publicly available. You need to make sure that other people can replicate your result. Other people can also see there what packages you have used.
12

Ok I realize this thread is 6 years old. So sorry for digging it up. However, maybe my routine is helpful to somebody else as well.

I usually do it pretty similar to Sverre, and cite in the main article R and the most important packages for my analyses. However, in addition I cite all packages in a table in the appendix with 4 columns (packagename, version, maintainer, citation).

Here is a small but useful snippet for this purpose. It creates a data.frame with 3 of the 4 mentioned columns and a .bib file with the required citations. Some manual work is still required (e.g. copy the .csv table into your word / text program and import the .bib to your citation management tool) to finish the appendix.
The snippet still saves me a lot of time.

# Export Citations as Bibtex (.bib)
write_bib(file="Bibliography of packages.bib")

# Table (.csv) with all information on the packages
appendix_packages <- data.frame(Packagename = character(),
                                Version = character(),
                                Maintainer = character())

require(pacman)
for (pkg in p_loaded()){
  appendix_packages <- appendix_packages %>% add_row(
    Packagename = pkg,
    Version = as.character(packageVersion(pkg)),
    Maintainer = maintainer(pkg)
  )
}

write.csv(x = appendix_packages, file = "List_of_packages.csv", row.names = F)

Edit August 2022

Disclosure I am the maintainer of the datscience R-package. As I used this function so frequently, I also included the Rcitation_appendix() function in the datscience package: Documentation Website, Code
Usage:

library(datscience)
library(lavaan)
Rcitation_appendix(filename="Appendix A - All R packages utilized.docx")

This creates a folder called 'Appendix' in the current directory and places two files in it, a .docx word file with the table and a .bib file for your reference manager. I later on manually enter the references in the most right column (Citation) enter image description here

1
  • 1
    the dataframe "appendix_packages" does not necessarily need to be exported, one can also directly turn it into a latex table via kable (see also this answer) Mar 18, 2021 at 16:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .