MyNixOS website logo
Description

Software Bibliographies for R Projects.

Detect libraries used in a project and automatically create software bibliographies in 'PDF', 'Word', 'Rmarkdown', and 'BibTeX' formats.

softbib: Software Bibliographies for R Projects

This package detects all the R libraries used in a project and automatically creates software bibliographies in PDF, Word, Rmarkdown, and BibTeX formats. Bibliographies can be printed in thousands of styles, using CSL files downloaded from the Zotero style repository.

Arel-Bundock, Vincent, and Joshua McCrain. 2023. “Software Citations in Political Science.” PS: Political Science & Politics, April, 1–4. https://doi.org/10.1017/S1049096523000239.

Installation

install.packages("softbib")

Or you can install the development version of softbib:

library(remotes)
install_github("vincentarelbundock/softbib")

Make sure you restart R for the change to take effect.

Getting started

Navigate to a project folder, crawl the working directory to get a list of R packages, and create bibliographies:

library(softbib)

setwd("~/path/to/my/R/project/")

softbib()

Exclude some packages from the bibliography:

softbib(exclude = c("base", "dplyr"))

Specify the list of packages to include manually:

softbib(include = c("countrycode", "modelsummary", "marginaleffects"))

Download a Citation Style Language file from the Zotero archive and print a bibliography in the style of the American Political Science Review:

download.file(
  "https://www.zotero.org/styles/american-political-science-review",
  destfile = "apsr.csl")

softbib(style = "apsr.csl")

Ignoring files and folders

softbib uses the renv::dependencies() function to detect R packages used in a project folder. Like the renv package, softbib can respect user instructions to ignore certain files and folders. To specify those ignore instructions, you must place a file called .renvignore in the working directory. This file can include lines such as:

ignorethiscript.R
ignorethisfolder/ignorethisscript2.R
ignorethisfolder/

LaTeX document with two bibliographies

It is relatively easy to insert a separate software bibliography in a LaTeX document by using the multibib package in a document preamble.

First, save this R script and execute it:

library(softbib)
library(countrycode)
softbib::softbib(output = "software.bib")

Then, save this LaTeX document in the same folder:

\documentclass{article}

\usepackage{multibib}
\newcites{softbib}{Software Bibliography}

% for this example we insert a bibtex entry in the main latex file instead of an external .bib file
\usepackage{filecontents}
\begin{filecontents*}{scientific.bib}
@article{arel2017unintended,
  title={The unintended consequences of bilateralism: Treaty shopping and international tax policy},
  author={Arel-Bundock, Vincent},
  journal={International Organization},
  volume={71},
  number={2},
  pages={349--371},
  year={2017},
  publisher={Cambridge University Press}
}
\end{filecontents*}

\begin{document}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus non ipsum nibh. Morbi in nibh feugiat, congue purus sed, accumsan nunc. Ut porttitor egestas purus ut eleifend. Praesent gravida mauris quis nibh faucibus facilisis. In quis sapien quis nisl accumsan malesuada in eget lectus. Sed tempor dapibus ligula malesuada volutpat \cite{arel2017unintended}. 

% bibliography
\bibliographystyle{plain}
\bibliography{scientific}

% software bibliography
\nocitesoftbib{*}
\bibliographystylesoftbib{plain}
\bibliographysoftbib{software}

\end{document}

Finally, run these commands:

pdflatex article
bibtex article
bibtex softbib
pdflatex article
pdflatex article

The result should look like this:

Metadata

Version

0.0.2

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows