LitFetchR (Tutorial)

Before continuing to the general package tutorial, make sure to have received your Scopus and Web of Science API keys. If not, the package will only access PubMed. If you don’t know how to get API keys, have a look at the article Get API keys.

Setup

We strongly recommend creating a new R directory for each individual review project. To do so in RStudio:

From your new directory, install LitFetchR from CRAN:

#This step can be skipped if `LitFetchR` is already installed
install.packages("LitFetchR")

Alternatively, install the development version from GitHub:

#Install using devtools package
install.packages("devtools")
devtools::install_github("thomasdumond/LitFetchR")

#or

#Install using remotes package
install.packages("remotes")
remotes::install_github("thomasdumond/LitFetchR")

Two optional packages are only needed for some functions:

install.packages("remotes")
remotes::install_github("camaradesuk/ASySD")

Then load the package:

#Load `LitFetchR`
library(LitFetchR)

Save API keys

Save your API keys in your personal R environment:

#This step can be skipped if your API keys have already been saved. Repeat this step if your API keys changed.

#Load `LitFetchR`
library(LitFetchR)

#Save API keys in your R environment

#Example of what you should see:
#> save_api_keys(wos_api_key = "abcd01234", scp_api_key = "efgh5678")
#Saved key(s) wos_api_key, scp_api_key to -path-to-your-renvironment/.Renviron.
#Restart R for the new environment variable(s) to be available.

This will allow LitFetchR to locally access your personal API keys while keeping them confidential if you need to share your code with collaborators.

save_api_keys() accepts the following, in any combination:

For instructions on how to obtain each of these, see Get API keys. The optional tokens can be saved at the same time as your keys, for example:

save_api_keys(scp_api_key = "efgh5678",
              scp_insttoken = "your-insttoken",
              ncbi_api_key = "your-ncbi-key")

As mentioned by R, it is important to restart your session before continuing:

Session>Restart R

Then load LitFetchR again using library(LitFetchR)

If you don’t have API keys for Scopus and Web of Science, see Get API keys.

Save the review search string(s)

The interactive create_save_search() function will guide you through its workflow. Here is an example of what you should see:

#Load LitFetchR
library(LitFetchR)

#The following function can help to create your search string(s)
#It has to be used to save your search string(s), we recommend choosing the R project directory as the directory in the function.

# Example of what you should see building the search: fish AND "vibrio harveyi" AND diagnostic
#
# > create_save_search(wos = TRUE,
#                      scp = TRUE,
#                      pmd = TRUE,
#                      directory = "C:/path-to-project-directory")
#
# History had been created.
# Enter your search string (or "summary" or "exit"): fish
# [1] "fish"
# [1] "Web of Science: 1793296 results"
# [1] "Scopus: 718644 results"
# [1] "PubMed: 384742 results"
# Enter your search string (or "summary" or "exit"): fish AND "vibrio harveyi"
# [1] "fish AND \"vibrio harveyi\""
# [1] "Web of Science: 2084 results"
# [1] "Scopus: 1080 results"
# [1] "PubMed: 727 results"
# Enter your search string (or "summary" or "exit"): fish AND "vibrio harveyi" AND diagnostic
# [1] "fish AND \"vibrio harveyi\" AND diagnostic"
# [1] "Web of Science: 126 results"
# [1] "Scopus: 22 results"
# [1] "PubMed: 106 results"
# Enter your search string (or "summary" or "exit"): summary
#                                Search_Term Results_WOS Results_SCP Results_PMD
# 1                                     fish     1793296      718644      384742
# 2                fish AND "vibrio harveyi"        2084        1080         727
# 3 fish AND "vibrio harveyi" AND diagnostic         126          22         106
# Do you want to save a search string for automated retrieval? (yes/no, Enter to cancel): yes
# Select the index number of the search string to save (1 to 3, Enter to cancel): 3
#
# Selected search string: fish AND "vibrio harveyi" AND diagnostic
#
# Enter a name for the search identification (Enter to cancel): fish_vibrio
# Search string saved successfully.
# Enter your search string (or "summary" or "exit"): exit
# Exiting search tool.

Typing exit before any search string was saved offers to save one, so a search is not lost by mistake. Every question can be cancelled by pressing Enter, and an invalid answer is asked again.

Exclusions: type NOT or AND NOT, LitFetchR writes the exclusion the way each platform requires (AND NOT for Scopus and NOT for PubMed and Web of Science). Phrases between double quotes are never changed.

After using create_save_search(), two new files will appear in your directory:

If you already validated your review search string, use create_save_search() to save the search string and setup the file required to continue toward the automation of reference retrieval.

Setup the automatic reference retrieval

The automated reference retrieval uses either Windows Task Scheduler or Cron (Mac/Linux). You do not have to specify it, LitFetchR will detect the system and setup the task for you using the following. On macOS and Linux the package cronR must be installed.

#Load LitFetchR
library(LitFetchR)
#We recommend choosing the R project directory as the directory in the function. It has to be the directory where "search_list.txt" and "history_search.xlsx" have been saved.
#We recommend using a single word for the *task_id* or to use underscores "_" to separate words.
#The retrieval frequency is currently available "DAILY", "WEEKLY" or "MONTHLY".
#You need to use a 24H format for the time of reference retrieval.
#For "WEEKLY", `day` is the weekday (MON, TUE, WED, THU, FRI, SAT or SUN).
#For "MONTHLY", `day` is the day of the month (1 to 28).
#If you do not give `day`, the weekday (or day of the month) of today is used.
#If you do not have an API key for WOS and/or SCP or want to exclude any database,
#change "TRUE" to "FALSE" in front of the corresponding database (e.g.`wos = FALSE`).

#Example of what you should see
#> auto_LitFetchR_setup(task_id = "fish_vibrio",
                     # when = "WEEKLY",
                     # time = "14:00",
                     # day = "MON",
                     # wos = TRUE,
                     # scp = TRUE,
                     # pmd = TRUE,
                     # directory = "C:/path-to-project-directory",
                     # dedup = FALSE,
                     # open_file = TRUE)
#To get a RIS file instead of a CSV file (for example for Covidence), add `output_format = "ris"`.
#Task scheduled!
#  Task name:  fish_vibrio
#  Recurrence: weekly on Monday at 14:00
#  Next run:   (date and time of the next run)
#  Status:     Ready

Task scheduled! is only shown after the scheduler accepted the task and the task was read back from it. Check the summary that follows: it is your proof that the retrieval will run. If the scheduler refuses the task, the function stops and shows the message of the scheduler. If the task cannot be confirmed, a warning is shown instead. A task with the same name is never overwritten, remove it first with remove_scheduled_task().

After running auto_LitFetchR_setup(), one new file is created in your directory:

Each time the task runs, the following files are created or updated:

Congratulations! Your automated reference retrieval is ready to work!

Good to know about scheduled retrieval

See also