Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Adding Bibliographies

Raw knitr supports the automatic generation of a bibliography for the packages attached into R. We can take advantage of this by specifying a LaTeX bibliography package like natbib. I prefer the (author, year) style and so I include the following in the preamble of my LaTeX documents.

\usepackage[authoryear]{natbib}

If we attach the rattle package, we might like to cite it with the following LaTeX command:

\citep{R-rattle}

This will produce a citation like (Williams, 2020). The “p” in \citep places the parentheses around the citation, without which we get Williams (2020).

Then we can ask knitr to generate bibliographic entries for each attached package:

write_bib(sub("^.*/", "", grep("^/", searchpaths(), value=TRUE)),
          file="mydoc.bib")

Note that the bibliography is saved to a file named mydoc.bib.

At the end of the LaTeX document, where we want the bibliography to appear, we add the following:

\bibliographystyle{jss}
\bibliography{mydoc}

See Page [*] to see what the bibliography will look like.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.