plume provides tools for handling and generating author-related information for scientific writing in R Markdown and Quarto. The package implements two R6 classes:
PlumeQuarto
: class that allows you to push author
metadata in YAML files or the YAML header of Quarto files. The generated
YAML complies with Quarto’s author and
affiliations schemas. This is the class to use if you work with
journal templates.
Plume
: class that generates author lists and other
author-related information as character strings. This is an easy and
convenient solution when you don’t need preformatted documents.
Install plume from CRAN with:
install.packages("plume")
Alternatively, you can install the development version of plume from GitHub with:
# install.packages("pak")
::pak("arnaudgallou/plume") pak
The minimal required data to work with plume classes is a data set containing given and family names but you would normally want to provide more information such as email addresses, ORCIDs, affiliations, etc.
library(plume)
encyclopedists#> # A tibble: 4 × 10
#> given_name family_name email phone orcid supervision writing note
#> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <chr>
#> 1 Denis Diderot dider… +1234 0000… 1 1 born…
#> 2 Jean-Jacques Rousseau rouss… <NA> 0000… NA 1 <NA>
#> 3 François-Marie Arouet aroue… <NA> <NA> NA 1 also…
#> 4 Jean Le Rond d'Alembert alemb… <NA> 0000… 1 1 born…
#> # ℹ 2 more variables: affiliation_1 <chr>, affiliation_2 <chr>
$new(encyclopedists)
Plume#> # A tibble: 4 × 11
#> id given_name family_name literal_name initials email phone orcid note
#> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 1 Denis Diderot Denis Dider… DD dide… +1234 0000… born…
#> 2 2 Jean-Jacques Rousseau Jean-Jacque… J-JR rous… <NA> 0000… <NA>
#> 3 3 François-Marie Arouet François-Ma… F-MA arou… <NA> <NA> also…
#> 4 4 Jean Le Rond d'… Jean Le Ron… JLRd'A alem… <NA> 0000… born…
#> # ℹ 2 more variables: affiliation <list>, role <list>
PlumeQuarto
lets you push author metadata in YAML files
or the YAML header of any .qmd
file using the
to_yaml()
method.
Consider the following example:
---
title: Encyclopédie
---
Qui scribit bis legit
<- PlumeQuarto$new(
aut
encyclopedists,file = "file.qmd"
)$set_corresponding_authors(1, 4)
aut$to_yaml() aut
---
title: Encyclopédie
author:
- id: aut1
name:
given: Denis
family: Diderot
email: diderot@encyclopediste.fr
phone: '+1234'
orcid: 0000-0000-0000-0001
note: born in 1713 in Langres
attributes:
corresponding: true
roles:
- Supervision
- Writing - original draft
affiliations:
- ref: aff1
- id: aut2
name:
given: Jean-Jacques
family: Rousseau
email: rousseau@encyclopediste.fr
orcid: 0000-0000-0000-0002
attributes:
corresponding: false
roles:
- Writing - original draft
affiliations:
- ref: aff2
- id: aut3
name:
given: François-Marie
family: Arouet
email: arouet@encyclopediste.fr
note: also known as Voltaire
attributes:
corresponding: false
roles:
- Writing - original draft
affiliations:
- ref: aff2
- id: aut4
name:
given: Jean
family: Le Rond d'Alembert
email: alembert@encyclopediste.fr
orcid: 0000-0000-0000-0003
note: born in 1717 in Paris
attributes:
corresponding: true
roles:
- Supervision
- Writing - original draft
affiliations:
- ref: aff1
- ref: aff3
affiliations:
- id: aff1
name: Université de Paris
- id: aff2
name: Lycée Louis-le-Grand
- id: aff3
name: Collège des Quatre-Nations
---
Qui scribit bis legit
Alternatively, you can generate author information as character
strings using Plume
:
<- Plume$new(encyclopedists)
aut $set_corresponding_authors(diderot, .by = "family_name")
aut
$get_author_list(suffix = "^a,^cn")
aut#> Denis Diderot^1,^\*†
#> Jean-Jacques Rousseau^2^
#> François-Marie Arouet^2^‡
#> Jean Le Rond d'Alembert^1,3^§
$get_contact_details()
aut#> diderot@encyclopediste.fr (Denis Diderot)
$get_affiliations()
aut#> ^1^Université de Paris
#> ^2^Lycée Louis-le-Grand
#> ^3^Collège des Quatre-Nations
$get_notes()
aut#> ^†^born in 1713 in Langres
#> ^‡^also known as Voltaire
#> ^§^born in 1717 in Paris
$get_contributions()
aut#> Supervision: D.D. and J.L.R.d'A.
#> Writing - original draft: D.D., J.-J.R., F.-M.A. and J.L.R.d'A.
<- Plume$new(
aut2
encyclopedists,roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
),symbols = list(affiliation = letters)
)
$get_author_list("^a^")
aut2#> Denis Diderot^a^
#> Jean-Jacques Rousseau^b^
#> François-Marie Arouet^b^
#> Jean Le Rond d'Alembert^a,c^
$get_contributions(roles_first = FALSE, divider = " ")
aut2#> D.D. and J.L.R.d'A. supervised the project
#> D.D., J.-J.R., F.-M.A. and J.L.R.d'A. contributed to the Encyclopédie
Thanks to:
Richard J. Telford for his advice that helped me conceive this package.
Maëlle Salmon and Gábor Csárdi for their help when I was stuck with unit tests, roxygen2 or pkgdown.