Movatterモバイル変換


[0]ホーム

URL:


Version:0.0.12
Encoding:UTF-8
Title:Interacting with BibTeX Databases
Depends:R(≥ 4.1)
Imports:methods, rcrossref, stringr, tools, utils, yamlme
Suggests:covr, devtools, rmarkdown, testthat
LazyData:true
SystemRequirements:pandoc (>= 1.14) - http://pandoc.org
Description:Reading and writing BibTeX files using data frames in R sessions.
License:GPL-2 |GPL-3 [expanded from: GPL (≥ 2)]
URL:https://kamapu.github.io/biblio/
BugReports:https://github.com/kamapu/biblio/issues
RoxygenNote:7.3.2
NeedsCompilation:no
Packaged:2025-09-10 22:36:40 UTC; miguel
Author:Miguel AlvarezORCID iD [aut, cre]
Maintainer:Miguel Alvarez <kamapu78@gmail.com>
Repository:CRAN
Date/Publication:2025-09-11 05:10:24 UTC

Coerce 'lib_df' objects

Description

Coercion 'lib_df' objects.

Arguments

x

An object to be coerced.

Examples

## Read installed libraryRefs <- read_bib(x = file.path(path.package("biblio"),        "LuebertPliscoff.bib"))# Convert lib_df to data frameas(Refs[1:5, ], "data.frame")# Convert lib_df to bibentryas(Refs[1:5, ], "bibentry")

Convert lib_df to bibentry

Description

Conversion method forlib_df objects intobibentry.

Usage

bib2bibentry(x, ...)## S3 method for class 'lib_df'bib2bibentry(x, ...)

Arguments

x

Alib_df object to be converted.

...

Further arguments passed among methods (not yet in use).

Value

Anbibentry object.

Examples

## Read installed electronic libraryBib <- read_bib(x = file.path(path.package("biblio"),        "LuebertPliscoff.bib"))## Convert the first five entriesbib2bibentry(Bib[1:5, ])

Compared libraries

Description

An S3 class for compared data frames. A list containing added, deletedentries on the regarding a key column and cells that are modified.


Compare data frames and libraries

Description

Report on differences between two versions of the same data frame orelectronic library.When used for data frames, you need to indicate the variable containing IDsfor each entry, while applied tolib_df objects, the variable'bibtexkey' will be considered as ID per default.

The output printed in the console will advice about added and deleted entriesin 'y' as well as any change in the entries common to both versions.

Usage

compare_df(x, y, key, ...)## S4 method for signature 'data.frame,data.frame,character'compare_df(x, y, key, ...)## S4 method for signature 'lib_df,lib_df,missing'compare_df(x, y, key, ...)

Arguments

x

The (old) reference data frame.

y

The updated (new) data frame.

key

A character value with the name of the variable used as primarykey in the tables.

...

Further arguments passed among methods.

Value

A S3 object of classcomp_df, which can be printed in the console byprint().

See Also

update(),lib_df,comp_df

Examples

# Partially matching librariesRefs1 <- synopsis[1:10, ]Refs2 <- synopsis[6:15, ]# some modification in second libraryRefs2[3, "title"] <- "New Title"# compare librariescompare_df(Refs1, Refs2)

Detect bibtexkeys used in an r-markdown document

Description

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

This function is based onbbt_detect_citations() from the packagerbbt.

Usage

detect_keys(x, ...)## S3 method for class 'character'detect_keys(x, ...)## S3 method for class 'rmd_doc'detect_keys(x, ...)

Arguments

x

A character vector, a file imported byreadLines() or an objectimported byyamlme::read_rmd(). If the character vector is the name of a Rmdor a Quarto document,readLines() will be internally called to read it.

...

Further arguments passed among methods. In character-method theyare passed toreadLines().

Value

A data frame with two columns,bibtexkey for the found keys andlinewith the line number of the occurrence of the key in the document.

Examples

## Screen for citations in installed documentcited_refs <- detect_keys(file.path(path.package("biblio"), "document.Rmd"))cited_refs

Downloading bibliogrphic references from DOIs

Description

Retrieving bibliographic entries from Crossref by DOIs.This function is a wrapper forrcrossref::cr_cn().

Usage

doi2bib(x, ...)

Arguments

x

A character vector including DOI identifiers.

...

Further arguments (not yet used).

Value

The output is an object of classlib_df.

Examples

## Retrieve bibliographic entries for two publicationsdois <- c("10.1111/1748-5967.12330",    "10.1016/j.envsci.2019.03.017")bibrefs <- doi2bib(dois)bibrefs

Insert new rows in a data frame

Description

Insert new rows in a data frame

Usage

insert_rows(x, y)

Electronic library

Description

An S3 class for library entries. This class inherits properties from dataframes.


Print content of lib_df objects

Description

A method for a brief overview on the content of alib_df or acomp_df object.

Usage

## S3 method for class 'lib_df'print(x, maxsum = 4, ...)## S3 method for class 'comp_df'print(x, ...)

Arguments

x

An object of class 'lib_df'.

maxsum

An integer value indicating the number of entries to bedisplayed in the printed output.

...

Further arguments passed among methods.

Value

A print in the console.

Author(s)

Miguel Alvarez

Examples

Refs <- read_bib(x = file.path(        path.package("biblio"),        "LuebertPliscoff.bib"    ))print(Refs, maxsum = 10)

Read BibTeX Databases

Description

Reading BibTeX databases and importing into R as a data frame. All the fieldswill be inserted as character values.

Usage

read_bib(x, ...)

Arguments

x

A single character value with the path to a BibTeX file.Alternativelly it can be a character vector containing the lines of aBibTeX library, for instance after usingreadLines().

...

Further arguments passed toreadLines().

Value

An object of classlib_df.

Examples

Refs <- read_bib(x = file.path(  path.package("biblio"),  "LuebertPliscoff.bib"))Refs

Write a Reference List in rmarkdown

Description

A fast way to produce a reference list in an r-markdown document from alib_df object.

This function may or may not produce intermediate files (bib and Rmd) and theresult can be assigned to an object for further edition(seeyamlme::update()).

A html file will be written byyamlme::write_rmd() andyamlme::render_rmd() in theworking directory and displayed bybrowseURL().

Usage

reflist(x, ...)## S3 method for class 'character'reflist(  x,  output_file,  delete_source = TRUE,  title = "Automatic Reference List",  output = "html_document",  nocite = "'@*'",  urlcolor = "blue",  encoding = "UTF-8",  ...)## S3 method for class 'lib_df'reflist(x, filename, delete_source = TRUE, ...)

Arguments

x

Alib_df object to produce the reference list. In the charactermethod, a character value indicating the path of a bibtex file(passed toread_bib()).

...

Further arguments passed to the yaml header in the intermediateRmarkdown document.

output_file

A character value with the name for the written Rmarkdownfile.

delete_source

A logical value indicating whether written bib file shouldbe deleted after rendering html or not.

title,output,nocite,urlcolor

Arguments used for the yaml-header inr-markdown and passed toyamlme::write_rmd(). They can be cancelled using thevalue NULL (not recommended for nocite).

encoding

A character value indicating the encoding string. It ispassed towrite_bib().

filename

A character value with the name for the written Rmd file,without file extension.

Value

An invisible object of classrmd_doc. A Rmd file will be written byyamlme::write_rmd() as well.

Examples

## Not run: reflist(synopsis)## End(Not run)

References by Lueber and Pliscoff (2018)

Description

Example of an object formatted aslib_df. This library is publishedwith the references of the bookBioclimatic and vegetational synopsis of Chile byLuebert and Pliscoff (2017).

Usage

synopsis

Format

An object of classlib_df (inherits fromdata.frame) with 1701 rows and 23 columns.

Source

doi:10.5281/zenodo.60800

Examples

data(synopsis)## Import from installed bibtex filesynopsis <- read_bib(x = file.path(  path.package("biblio"),  "LuebertPliscoff.bib"))

Update data frames

Description

This function compares two versions of the same data frame and detect changesas additions, deleted entries or updates (modified entries).

A method to comparelib_df objects is also provided as well as areplace method.

Usage

update_data(object, revision, key, ...)## S4 method for signature 'data.frame,data.frame,character'update_data(  object,  revision,  key,  add = FALSE,  delete = FALSE,  update = FALSE,  ...)## S4 method for signature 'lib_df,lib_df,missing'update_data(object, revision, key, ...)update_data(object, key, ...) <- value## S4 replacement method for signature 'data.frame,character,data.frame'update_data(object, key, ...) <- value## S4 replacement method for signature 'lib_df,missing,lib_df'update_data(object, key, ...) <- value

Arguments

object

A data frame or alib_df object representing theoriginal version.

revision

The updated version of 'object' to be compared.

key

A character value indicating the column used as identifier. Thisvariable have to be in both versions otherwise this function willretrieve an error.

...

Further arguments passed among methods.

delete,add,update

Logical value indicating whether the actionshould be carried out. If all are'FALSE', this function will justreport differences as done bycompare_df.

value

The updated version of 'object' in the replace methods.

Value

Either an invisible output with a print in the console or an updated objectof classlib_df.

Examples

# Adding an ID to data set irisiris2 <- irisiris2$id <- 1:nrow(iris2)# rows to add using mean values per speciesiris_mod <- aggregate(cbind(  Sepal.Length, Sepal.Width, Petal.Length,  Petal.Width) ~ Species, data = iris2, FUN = mean)iris_mod$id <- (1:nrow(iris_mod)) + nrow(iris2)iris_mod <- do.call(rbind, list(iris2, iris_mod[, colnames(iris2)]))# delete some entriesiris_mod <- iris_mod[-c(15, 75, 105, 145), ]# modify entriesiris_mod$Petal.Length[c(20, 30)] <- 0iris_mod$Petal.Width[c(20, 50)] <- 0# just a comparisonupdate_data(iris2, iris_mod, key = "id")# do updateiris2 <- update_data(iris2, iris_mod,  key = "id", delete = TRUE, add = TRUE,  update = TRUE)

Write BibTeX Files

Description

BibTeX databases can be created from data frames, interacting with Postgresdatabases.

Usage

write_bib(x, ...)## S3 method for class 'lib_df'write_bib(x, filename, encoding = "UTF-8", ...)

Arguments

x

A data frame with bibliographic entries.

...

Further arguments passed tofile().

filename

A character value with the path and the name of the file tobe written.

encoding

Character value with the encoding (passed tofile()).

Value

A bibtex file.


[8]ページ先頭

©2009-2025 Movatter.jp