-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
127 lines (89 loc) · 3.55 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
warning = FALSE,
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# plume
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/plume)](https://CRAN.R-project.org/package=plume)
[![R-CMD-check](https://github.com/arnaudgallou/plume/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/arnaudgallou/plume/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/arnaudgallou/plume/branch/main/graph/badge.svg)](https://app.codecov.io/gh/arnaudgallou/plume?branch=main)
<!-- badges: end -->
## Overview
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](https://quarto.org/docs/journals/authors.html). 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.
## Installation
Install plume from CRAN with:
```{r, eval = FALSE}
install.packages("plume")
```
Alternatively, you can install the development version of plume from GitHub with:
```{r, eval = FALSE}
# install.packages("pak")
pak::pak("arnaudgallou/plume")
```
## Usage
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.
```{r, message = FALSE}
library(plume)
encyclopedists
Plume$new(encyclopedists)
```
```{r, include = FALSE}
tmp_file <- withr::local_tempfile(
lines = "---\ntitle: Encyclopédie\n---\n\nQui scribit bis legit",
fileext = ".qmd"
)
```
`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:
```{r, echo = FALSE, comment = ""}
cat(readr::read_file(tmp_file))
```
```{r, eval = FALSE}
aut <- PlumeQuarto$new(
encyclopedists,
file = "file.qmd"
)
aut$set_corresponding_authors(1, 4)
aut$to_yaml()
```
```{r, echo = FALSE, comment = ""}
aut <- PlumeQuarto$new(encyclopedists, tmp_file)
aut$set_corresponding_authors(1, 4)
aut$to_yaml()
cat(readr::read_file(tmp_file))
```
Alternatively, you can generate author information as character strings using `Plume`:
```{r, message = FALSE}
aut <- Plume$new(encyclopedists)
aut$set_corresponding_authors(diderot, .by = "family_name")
aut$get_author_list(suffix = "^a,^cn")
aut$get_contact_details()
aut$get_affiliations()
aut$get_notes()
aut$get_contributions()
aut2 <- Plume$new(
encyclopedists,
roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
),
symbols = list(affiliation = letters)
)
aut2$get_author_list("^a^")
aut2$get_contributions(roles_first = FALSE, divider = " ")
```
## Acknowledgements
Thanks to:
* [Richard J. Telford](https://github.com/richardjtelford) for his advice that helped me conceive this package.
* [Maëlle Salmon](https://github.com/maelle) and [Gábor Csárdi](https://github.com/gaborcsardi) for their help when I was stuck with unit tests, roxygen2 or pkgdown.