Zotero is a free, cross-platform tool to help you collect, organize, cite, and share your research sources. Zotero is similar to Mendeley or EndNote.
The purpose of this chapter is to show how Zotero can be used as a reference manager to allow you to cite works in your book, and automatically compile bibliographies or reference sections. The bookdown package uses Latex bibliography files to generate citations and create bibliographies. These .bib files are text-based files with a specific syntax for coding the relevant information in a citation. Each citation in a .bib file has an associated key that is inserted into an Rmarkdown document to generate a citation. We will use Zotero to avoid writing our own .bib from scratch. Instead, there are convenient methods for populating Zotero with a database of references, and for compiling a .bib file from a Zotero databse that can be used in bookdown.
Zotero operates on the cloud as well as on your desktop. You can connect your online Zotero account with your desktop app in the preferences.
There are multiple ways to import references into Zotero. In the Zotero desktop app you can create folders to organize your references.
Zotero is fairly flexible, so the above process will generally work when you are accessing many different databases, and journal web-pages for specific articles.
The citation information that Zotero downloads is sometimes inaccurate. Be sure to check the fields for each of your citations to ensure they are accurate. For example, page ranges are often missing.
Citations are add using the following format @citationkey
, or [@citationkey]
to place the author,year citation in parentheses. The citation key name is listed for each citation in the bib file. Here are a couple of links with some additional examples: examples from bookdown, and examples from RMarkdown.
The source code for this book contains two .bib files: book.bib and packages.bib. Each citation in those files has an associated citation key. Here is an example of citing the bookdown package [@xie2015]. This is an example of citing R-core team [@R-base]
A minor inconvenience when using .bib for citations in Rmarkdown is that you have to know the citation key, and these are easy to forget. One option is to load up your .bib file, then search through it to find the citation key.
Another option is to download and install the citr
package. Once this package is installed, you can use its cite while your write feature. Click the tools menu, addins, then, insert citations. This will open up a window showing all of the citations in your bib files. You can click multiple citations, and then insert the citation keys into your Rmarkdown document. This is convenient method for quickly finding needed citation keys. I recommend first openining the index.rmd file (which points to your .bib files), and then opening the insert citations tools; this will allow the tool to find your .bib files. After this point, you should be able to use the tool when you are working within .Rmd files for each chapter.
require(tidyverse) #import datat #test # dat <- readFiles("https://www.bibliometrix.org/datasets/savedrecs.bib") # str(dat) # # M <- convert2df(dat, dbsource = "isi", format = "bibtex") # names(M)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.