The R package litsearchr provides various functions to help with planning a systematic search of the scientific literature on a given topic. This tutorial gives an example of how to use litsearchr, along with some brief explanations of its workings.

litsearchr was created by the amazing Eliza Grames, and a lot of this tutorial is an elaboration of the existing vignette for the package.


As well as litsearchr itself, we will use a few other R packages in the tutorial. Let’s load them.



To use the litsearchr package, we need to install it first.

litsearchr isn’t (yet) stored in the package repository of CRAN, the Comprehensive R Archive Network. This means that the usual install.packages() function or the Install button in RStudio won’t find it. Instead, we can install the package from Eliza’s GitHub repository.

The devtools package provides a function for installing R packages from GitHub instead of from CRAN. So we can use this.

install_github("elizagrames/litsearchr", ref="main")

Now that we have installed litsearchr we can load it.


litsearchr is a new package and is currently in development. So we should keep track of which version we are using, in case we later work with a newer version and find that the examples in this tutorial no longer work.

## [1] '1.0.0'


Let’s imagine that we want to retrieve journal articles about treating phobias with a combination of medication and cognitive-behavioral therapy. Our overall topic consists of the three sub-topics medication, CBT and phobia, and we want to get articles that are about all three.

The starting point in litsearchr is an existing search that we have already carried out. We first conduct a quick, cursory search for our topic of interest. This is known as the ‘naive search’. litsearchr will then take the results of our naive search and suggest improvements that might capture more articles that are relevant to our topic (and hopefully fewer that are not relevant).

We start by going to the PubMed search page and enter the search in the Query box there. For this example, I entered the following three search terms, combined with AND, like this:

(medication) AND (CBT) AND (phobia)

If you click on the Send to button above the PubMed search results, and then select to send them to Citation manager, you will be prompted to download all the results to a file that litsearchr can read. I have downloaded the example results to a file called pubmed-medication-set.nbib.

Loading results

We can load results from a file using the litsearchr function import_results(). We give the file name as the file argument.

naive_results <- import_results(file="pubmed-medication-set.nbib")
## Reading file pubmed-medication-set.nbib ... done

import_results() gives us a dataframe in which each result is a row. We can see from the number of rows how many results our search got.

## [1] 133

We can take a look at the first few.