---
title: "Manual reference retrieval"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{manual_fetch}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

If you are here, this is because you want to manually retrieve a list of references, outside of the automated task that you might have set up after reading [LitFetchR (Tutorial)](https://thomasdumond.github.io/LitFetchR/articles/LitFetchr.html).

## Setup
From your individual review R directory, load `LitFetchR`:
```{r, eval = FALSE}
# Load LitFetchR
library(LitFetchR)
```

## Manual reference retrieval
Make sure to have saved your search string using `create_save_search()` as the following function needs to access the file *search_list.txt*, see [LitFetchR (Tutorial)](https://thomasdumond.github.io/LitFetchR/articles/LitFetchr.html).

```{r, eval=FALSE}
# Load LitFetchR
library(LitFetchR)

# Retrieve the list of references corresponding to your saved search string(s)
#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.

# Example of what you should see: 
# > manual_fetch(wos = TRUE,
#                scp = TRUE,
#                pmd = TRUE,
#                directory = "C:/path-to-project-directory",
#                dedup = TRUE,
#                open_file = FALSE)
# [1] 126
# Finished batch number 1
# Finished batch number 2
# [1] "10.1016/j.aaf.2023.11.002 1 / 126"
# [1] "10.3390/fishes10090439 2 / 126"
# [FOR THE PURPOSE OF THIS EXAMPLE WE ARE NOT SHOWING EACH LINE OF THE COMMAND]
# [THE REMOVED LINES CORRESPOND TO MOST OF THE REFERENCE RETRIEVAL COUNTING]
# [1] "NA 125 / 126"
# [1] "NA 126 / 126"
# [1] 22
# Finished batch number 1
# File already exists
# [1] "10.1007/s12602-023-10207-x 1 / 22"
# [1] "10.1016/j.fsi.2025.110189 2 / 22"
# [FOR THE PURPOSE OF THIS EXAMPLE WE ARE NOT SHOWING EACH LINE OF THE COMMAND]
# [THE REMOVED LINES CORRESPOND TO MOST OF THE REFERENCE RETRIEVAL COUNTING]
# [1] "10.1111/j.1472-765X.2010.02894.x 21 / 22"
# [1] "NA 22 / 22"
# [1] 106
# Finished batch 1 for fish AND "vibrio harveyi" AND diagnostic
# File already exists
# [1] "10.1016/j.fsi.2025.110503 1 / 106"
# [1] "10.1016/j.fsi.2025.110501 2 / 106"
# [FOR THE PURPOSE OF THIS EXAMPLE WE ARE NOT SHOWING EACH LINE OF THE COMMAND][1] "NA 105 / 106"
# [THE REMOVED LINES CORRESPOND TO MOST OF THE REFERENCE RETRIEVAL COUNTING]
# [1] "NA 106 / 106"
# Warning: The following columns are missing: pages, number, record_id, isbn
# formatting data...
# identifying potential duplicates...
# identified duplicates!
# flagging potential pairs for manual dedup...
# Joining with `by = join_by(duplicate_id.x, duplicate_id.y)`
# 254 citations loaded...
# 14 duplicate citations removed...
# 240 unique citations remaining!
# Deduplication script has been executed, concatenated deduplicated references had been exported.
# Warning message:
# In add_missing_cols(raw_citations) :
#   Search contains missing values for the record_id column. A record_id will be created using row numbers
```

After running `manual_fetch()`, new unique *history_dedup_* and *citationCSV_* files are created and *history_id* is updated. See bottom of the page [LitFetchR (Tutorial)](https://thomasdumond.github.io/LitFetchR/articles/LitFetchr.html) for more information about those files.
