R Craft: Get Software Citations for Reproducible Research

Healthy research requires reproducibility, but R works with so many community-sourced packages that tracking each one’s impact can seem daunting. How can you do it? R’s citation function makes citing R libraries simple.

R software logo

By default, citation() returns details for citing base R. Add a package name (e.g.: citation(“ggplot2”)) to get its details. Use lots of libraries? You’ll have to run citation for each library you load, so try a loop:

package_names <- c("ggplot2", "tidyr", "stargazer")
for(i in package_names){

The citation function displays citation information documented within each package. If a package author skipped that step, however, the software will generate a citation automatically so you won’t have to think about it. Just run the code!

Citations typically print in both a plain text version for copying into your text editor and in a BibTeX version for use with LaTeX, R Markdown, or other TeX-friendly editors. If you want BibTeX only or BibTeX when only plain text appears, use the toBibtex function on your citation output (e.g.: toBibtex(citation("ggplot2"))).

Software citations work hand-in-hand with documenting data sources and analysis steps to make your research reproducible, and R makes getting the details straightforward. How will you incorporate citation into your research workflow?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s