Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update encyclopedists role columns #39

Merged
merged 2 commits into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# plume (development version)

* Updated the `encyclopedists` and `encyclopedists_fr` data to use the new role column system (#39).

* `$to_yaml()` now preserves line breaks preceding leading or isolated `---` (#37).

* `plm_template()` now returns role columns as numeric type (#26).
Expand Down
4 changes: 2 additions & 2 deletions R/data-encyclopedists.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#' \item{phone,téléphone}{authors' phone numbers}
#' \item{orcid}{authors' ORCID}
#' \item{affiliation}{authors' affiliations}
#' \item{role_n}{authors' roles written as nouns}
#' \item{role_v}{authors' roles written as active verbs}
#' \item{supervision}{authors that supervised the project}
#' \item{writing,rédaction}{authors involved in the writing}
#' \item{note}{special notes about authors}
#' }
#' @examples
Expand Down
6 changes: 2 additions & 4 deletions R/plume-quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
#' # you've just created
#' aut <- PlumeQuarto$new(
#' encyclopedists,
#' file = tmp_file,
#' names = c(role = "role_n")
#' file = tmp_file
#' )
#'
#' # And push author data to the YAML header
Expand All @@ -41,8 +40,7 @@
#' # header accordingly
#' aut <- PlumeQuarto$new(
#' dplyr::slice(encyclopedists, 2),
#' file = tmp_file,
#' names = c(role = "role_n")
#' file = tmp_file
#' )
#' aut$to_yaml()
#'
Expand Down
7 changes: 5 additions & 2 deletions R/plume.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' information as character strings.
#' @examples
#' # Create a Plume instance
#' aut <- Plume$new(encyclopedists, names = c(role = "role_n"))
#' aut <- Plume$new(encyclopedists)
#'
#' # Set the desired corresponding authors, using
#' # authors' id by default
Expand Down Expand Up @@ -41,7 +41,10 @@
#'
#' # It is also possible to output contributions in the
#' # active voice
#' aut <- Plume$new(encyclopedists, names = c(role = "role_v"))
#' aut <- Plume$new(encyclopedists, roles = c(
#' supervision = "supervised the project",
#' writing = "contributed to the Encyclopédie"
#' ))
#' aut$get_contributions(roles_first = FALSE, divider = " ")
#' @export
Plume <- R6Class(
Expand Down
18 changes: 10 additions & 8 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ cat(readr::read_file(tmp_file))
```{r, eval = FALSE}
aut <- PlumeQuarto$new(
encyclopedists,
file = "file.qmd",
names = c(role = "role_n")
file = "file.qmd"
)
aut$set_corresponding_authors(1, 4)
aut$to_yaml()
```

```{r, echo = FALSE, comment = ""}
aut <- PlumeQuarto$new(encyclopedists, tmp_file, names = c(role = "role_n"))
aut <- PlumeQuarto$new(encyclopedists, tmp_file)
aut$set_corresponding_authors(1, 4)
aut$to_yaml()
cat(readr::read_file(tmp_file))
Expand All @@ -92,7 +91,7 @@ cat(readr::read_file(tmp_file))
Alternatively, you can generate author information as character strings using `Plume`:

```{r, message = FALSE}
aut <- Plume$new(encyclopedists, names = c(role = "role_n"))
aut <- Plume$new(encyclopedists)
aut$set_corresponding_authors(diderot, by = "family_name")

aut$get_author_list(format = "^a,^cn") |> enumerate(last = ",\n")
Expand All @@ -105,15 +104,18 @@ aut$get_notes()

aut$get_contributions()

aut_v <- Plume$new(
aut2 <- Plume$new(
encyclopedists,
names = c(role = "role_v"),
roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
),
symbols = list(affiliation = letters)
)

aut_v$get_author_list(format = "^a^") |> enumerate(last = ",\n")
aut2$get_author_list(format = "^a^") |> enumerate(last = ",\n")

aut_v$get_contributions(roles_first = FALSE, divider = " ")
aut2$get_contributions(roles_first = FALSE, divider = " ")
```

## Acknowledgements
Expand Down
42 changes: 22 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ more information such as email addresses, ORCIDs, affiliations, etc.
library(plume)

encyclopedists
#> # A tibble: 4 × 12
#> given_name family_name email phone orcid role_n1 role_n2 role_v1 role_v2 note
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Denis Diderot dide… 00 0… 0000… Writing Superv… contri… superv… born…
#> 2 Jean-Jacq… Rousseau rous… <NA> 0000… Writing <NA> contri… <NA> <NA>
#> 3 François- Arouet arou… <NA> <NA> Writing <NA> contri… <NA> also…
#> 4 Jean Le Rond d'… alem… <NA> 0000… Writing Superv… contri… superv… born…
#> # 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… 00 0… 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: affiliation1 <chr>, affiliation2 <chr>

Plume$new(encyclopedists)
Expand Down Expand Up @@ -88,8 +88,7 @@ Consider the following example:
``` r
aut <- PlumeQuarto$new(
encyclopedists,
file = "file.qmd",
names = c(role = "role_n")
file = "file.qmd"
)
aut$set_corresponding_authors(1, 4)
aut$to_yaml()
Expand All @@ -109,8 +108,8 @@ aut$to_yaml()
attributes:
corresponding: true
roles:
- writing
- supervision
- writing - original draft
affiliations:
- ref: aff1
- id: aut2
Expand All @@ -122,7 +121,7 @@ aut$to_yaml()
attributes:
corresponding: false
roles:
- writing
- writing - original draft
affiliations:
- ref: aff2
- id: aut3
Expand All @@ -134,7 +133,7 @@ aut$to_yaml()
attributes:
corresponding: false
roles:
- writing
- writing - original draft
affiliations:
- ref: aff2
- id: aut4
Expand All @@ -147,8 +146,8 @@ aut$to_yaml()
attributes:
corresponding: true
roles:
- writing
- supervision
- writing - original draft
affiliations:
- ref: aff1
- ref: aff3
Expand All @@ -167,7 +166,7 @@ Alternatively, you can generate author information as character strings
using `Plume`:

``` r
aut <- Plume$new(encyclopedists, names = c(role = "role_n"))
aut <- Plume$new(encyclopedists)
aut$set_corresponding_authors(diderot, by = "family_name")

aut$get_author_list(format = "^a,^cn") |> enumerate(last = ",\n")
Expand All @@ -188,22 +187,25 @@ aut$get_notes()
#> ^§^born in 1717 in Paris

aut$get_contributions()
#> Writing: D.D., J.-J.R., F.-M.A. and J.L.R.d'A.
#> 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.

aut_v <- Plume$new(
aut2 <- Plume$new(
encyclopedists,
names = c(role = "role_v"),
roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
),
symbols = list(affiliation = letters)
)

aut_v$get_author_list(format = "^a^") |> enumerate(last = ",\n")
aut2$get_author_list(format = "^a^") |> enumerate(last = ",\n")
#> Denis Diderot^a^, Jean-Jacques Rousseau^b^, François-Marie Arouet^b^,
#> Jean Le Rond d'Alembert^a,c^

aut_v$get_contributions(roles_first = FALSE, divider = " ")
#> D.D., J.-J.R., F.-M.A. and J.L.R.d'A. contributed to the Encyclopédie
aut2$get_contributions(roles_first = FALSE, divider = " ")
#> 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
```

## Acknowledgements
Expand Down
Binary file modified data/encyclopedists.rda
Binary file not shown.
Binary file modified data/encyclopedists_fr.rda
Binary file not shown.
7 changes: 5 additions & 2 deletions man/Plume.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions man/PlumeQuarto.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/encyclopedists.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 11 additions & 24 deletions vignettes/plume.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,13 @@ Plume$new(
family_name = "nom",
literal_name = "nom_complet",
email = "courriel",
initials = "initiales",
role = "role_v"
initials = "initiales"
)
)
```

## Defining roles and contributors

::: {.alert .alert-warning}
This feature is currently only available in the development version of plume.
:::

You can add roles by creating specific role columns in the input data and indicate contributors using a `1`:

```{r, echo = FALSE}
Expand All @@ -156,7 +151,7 @@ plume uses `r plume:::link("crt")` (CRediT) by default (assuming the input data
```{r, eval = FALSE}
Plume$new(data, roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
writing = "contributed to the writing"
))
```

Expand All @@ -182,18 +177,13 @@ You can push information from the input data into the YAML header using the `to_
```{r, eval = FALSE}
aut <- PlumeQuarto$new(
dplyr::slice(encyclopedists, 1, 4),
file = "file.qmd",
names = c(role = "role_n")
file = "file.qmd"
)
aut$to_yaml()
```

```{r, echo = FALSE, comment = ""}
aut <- PlumeQuarto$new(
dplyr::slice(encyclopedists, 1, 4),
tmp_file,
names = c(role = "role_n")
)
aut <- PlumeQuarto$new(dplyr::slice(encyclopedists, 1, 4), tmp_file)
aut$to_yaml()
cat(read_file(tmp_file))
```
Expand All @@ -205,18 +195,13 @@ If the YAML header already has an `author` and `affiliations` keys, `to_yaml()`
```{r, eval = FALSE}
aut <- PlumeQuarto$new(
dplyr::slice(encyclopedists, 2),
file = "file.qmd",
names = c(role = "role_n")
file = "file.qmd"
)
aut$to_yaml()
```

```{r, echo = FALSE, comment = ""}
aut <- PlumeQuarto$new(
dplyr::slice(encyclopedists, 2),
tmp_file,
names = c(role = "role_n")
)
aut <- PlumeQuarto$new(dplyr::slice(encyclopedists, 2), tmp_file)
aut$to_yaml()
cat(read_file(tmp_file))
```
Expand Down Expand Up @@ -334,7 +319,6 @@ aut$get_contact_details(format = "{name}: {details}")
plume provides a convenient way to generate contribution lists using the `get_contributions()` method.

```{r}
aut <- Plume$new(encyclopedists, names = c(role = "role_n"))
aut$get_contributions()

aut$get_contributions(
Expand All @@ -343,8 +327,11 @@ aut$get_contributions(
literal_names = TRUE
)

aut_v <- Plume$new(encyclopedists, names = c(role = "role_v"))
aut_v$get_contributions(roles_first = FALSE, divider = " ")
aut2 <- Plume$new(encyclopedists, roles = c(
supervision = "supervised the project",
writing = "contributed to the Encyclopédie"
))
aut2$get_contributions(roles_first = FALSE, divider = " ")
```

By default, `get_contributions()` lists contributors in the order they're defined. You can arrange contributors in alphabetical order with `alphabetical_order = TRUE`:
Expand Down