Skip to contents

This function screens a character vector (usually an imported r-markdown document) for the use of citations by bibtexkeys (@bibtexkey), retrieving the detected key with its occurrence in the vector, assuming each element as a line of the original document.

This function is based on bbt_detect_citations() from the package rbbt.

Usage

detect_keys(x, ...)

# S3 method for character
detect_keys(x, ...)

# S3 method for rmd_doc
detect_keys(x, ...)

Arguments

x

A character vector, a file imported by readLines() or an object imported by read_rmd(). If the character vector is the name of a Rmd or a Quarto document, readLines() will be internally called to read it.

...

Further arguments passed among methods. In character-method they are passed to readLines().

Value

A data frame with two columns, bibtexkey for the found keys and line

with the line number of the occurrence of the key in the document.

Examples

## Screen for citations in installed document
cited_refs <- detect_keys(file.path(path.package("biblio"), "document.Rmd"))
cited_refs
#>        bibtexkey line
#> 1 oberdorfer1960   10
#> 2     veblen1995   12
#> 3     veblen1996   12
#> 4 oberdorfer1960   15
#> 5 oberdorfer1960   19
#> 6     veblen1996   24
#> 7   pollmann2004   24
#> 8    ramirez2005   29