Crosswalk

From R to CFF

Diego Hernangómez

The goal of this vignette is to provide an explicit map between the metadata fields used by cffr and each one of the valid keys of the Citation File Format schema version 1.2.0.

Summary

We summarize here the fields that cffr can parse and the original source of information for each one of them. The details on each key are presented on the next section of the document. The assessment of fields are based on the Guide to Citation File Format schema version 1.2.0 (Druskat et al. 2021).

key source
abstract DESCRIPTION file
authors DESCRIPTION file
cff-version parameter on function
commit Not parsed by cffr
contact DESCRIPTION file
date-released DESCRIPTION file
doi CITATION file
identifiers DESCRIPTION/CITATION files
keywords DESCRIPTION file
license DESCRIPTION file
license-url Not parsed by cffr
message DESCRIPTION file
preferred-citation CITATION file
references CITATION file
repository DESCRIPTION file
repository-artifact Not parsed by cffr
repository-code DESCRIPTION file
title DESCRIPTION file
type Fixed value: ‘software’
url DESCRIPTION file
version DESCRIPTION file

Details

abstract

This key is extracted from the “Description” field of the DESCRIPTION file.

Example

library(cffr)

# Create cffr for yaml

cff_obj <- cff_create("rmarkdown")

# Get DESCRIPTION of rmarkdown to check

pkg <- desc::desc(file.path(find.package("rmarkdown"), "DESCRIPTION"))

cat(cff_obj$abstract)
#> Convert R Markdown documents into a variety of formats.

cat(pkg$get("Description"))
#> Convert R Markdown documents into a variety of formats.

Back to summary.

authors

This key is parsed from the “Authors” or “Authors@R” field of the DESCRIPTION file. Only persons with the role “aut” or “cre” are considered.

Example

cff_obj <- cff_create("rmarkdown")
pkg <- desc::desc(file.path(find.package("rmarkdown"), "DESCRIPTION"))

cff_obj$authors
#> - family-names: Allaire
#>   given-names: JJ
#>   email: jj@rstudio.com
#> - family-names: Xie
#>   given-names: Yihui
#>   email: xie@yihui.name
#>   orcid: https://orcid.org/0000-0003-0645-5666
#> - family-names: McPherson
#>   given-names: Jonathan
#>   email: jonathan@rstudio.com
#> - family-names: Luraschi
#>   given-names: Javier
#>   email: javier@rstudio.com
#> - family-names: Ushey
#>   given-names: Kevin
#>   email: kevin@rstudio.com
#> - family-names: Atkins
#>   given-names: Aron
#>   email: aron@rstudio.com
#> - family-names: Wickham
#>   given-names: Hadley
#>   email: hadley@rstudio.com
#> - family-names: Cheng
#>   given-names: Joe
#>   email: joe@rstudio.com
#> - family-names: Chang
#>   given-names: Winston
#>   email: winston@rstudio.com
#> - family-names: Iannone
#>   given-names: Richard
#>   email: rich@rstudio.com
#>   orcid: https://orcid.org/0000-0003-3925-190X

authors <- pkg$get_authors()

authors[vapply(authors, function(x) {
  "aut" %in% x$role || "cre" %in% x$role
}, logical(1))]
#>  [1] "JJ Allaire <jj@rstudio.com> [aut]"                                                 
#>  [2] "Yihui Xie <xie@yihui.name> [aut, cre] (<https://orcid.org/0000-0003-0645-5666>)"   
#>  [3] "Jonathan McPherson <jonathan@rstudio.com> [aut]"                                   
#>  [4] "Javier Luraschi <javier@rstudio.com> [aut]"                                        
#>  [5] "Kevin Ushey <kevin@rstudio.com> [aut]"                                             
#>  [6] "Aron Atkins <aron@rstudio.com> [aut]"                                              
#>  [7] "Hadley Wickham <hadley@rstudio.com> [aut]"                                         
#>  [8] "Joe Cheng <joe@rstudio.com> [aut]"                                                 
#>  [9] "Winston Chang <winston@rstudio.com> [aut]"                                         
#> [10] "Richard Iannone <rich@rstudio.com> [aut] (<https://orcid.org/0000-0003-3925-190X>)"

Back to summary.

cff-version

This key can be set via the parameters of the cff_create()/cff_write() functions:

Example

cff_objv110 <- cff_create("jsonlite", cff_version = "v1.1.0")

cat(cff_objv110$`cff-version`)
#> v1.1.0

Back to summary.

commit

This key is not extracted from the metadata of the package. See the description on the Guide to CFF schema v1.2.0.

  • description: The commit hash or revision number of the software version.

  • usage:

    commit: 1ff847d81f29c45a3a1a5ce73d38e45c2f319bba
    
    commit: "Revision: 8612"

Back to summary.

contact

This key is parsed from the “Authors” or “Authors@R” field of the DESCRIPTION file. Only persons with the role “cre” (i.e, the maintainer(s)) are considered.

Example

cff_obj <- cff_create("rmarkdown")
pkg <- desc::desc(file.path(find.package("rmarkdown"), "DESCRIPTION"))

cff_obj$contact
#> - family-names: Xie
#>   given-names: Yihui
#>   email: xie@yihui.name
#>   orcid: https://orcid.org/0000-0003-0645-5666

pkg$get_author()
#> [1] "Yihui Xie <xie@yihui.name> [aut, cre] (<https://orcid.org/0000-0003-0645-5666>)"

Back to summary.

date-released

This key is parsed from the “Date” field or, if not present, from the “Date/Publication” field that is present on packages built on CRAN.

Example

# From an installed package

cff_obj <- cff_create("rmarkdown")
pkg <- desc::desc(file.path(find.package("rmarkdown"), "DESCRIPTION"))


cat(pkg$get("Date/Publication"))
#> 2021-09-14 14:10:02 UTC


cat(cff_obj$`date-released`)
#> 2021-09-14



# A DESCRIPTION file without a Date
nodate <- system.file("examples/DESCRIPTION_basic", package = "cffr")
tmp <- tempfile("DESCRIPTION")

# Create a temporary file
file.copy(nodate, tmp)
#> [1] TRUE


pkgnodate <- desc::desc(tmp)
cffnodate <- cff_create(tmp)

# Won't appear
cat(cffnodate$`date-released`)

pkgnodate
#> Type: Package
#> Package: basicdesc
#> Title: A Basic Description
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: A very basic description. Should parse without problems.
#> License: GPL-3
#> URL: https://github.com/basic/package, https://basic.github.io/package
#> BugReports: https://github.com/basic/package/issues
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000

# Adding a Date

desc::desc_set("Date", "1999-01-01", file = tmp)
#> Type: Package
#> Package: basicdesc
#> Title: A Basic Description
#> Version: 0.1.6
#> Date: 1999-01-01
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: A very basic description. Should parse without problems.
#> License: GPL-3
#> URL: https://github.com/basic/package, https://basic.github.io/package
#> BugReports: https://github.com/basic/package/issues
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000

cat(cff_create(tmp)$`date-released`)
#> 1999-01-01

Back to summary.

doi

This key is parsed from the “doi” field of the preferred-citation object.

Example

cff_doi <- cff_create("cffr")

cat(cff_doi$doi)
#> 10.5281/zenodo.5509765

cat(cff_doi$`preferred-citation`$doi)
#> 10.5281/zenodo.5509765

Back to summary.

identifiers

This key includes all the possible identifiers of the package:

Example
file <- system.file("examples/DESCRIPTION_many_urls", package = "cffr")

pkg <- desc::desc(file)

cat(pkg$get_urls())
#> https://github.com/test/package https://test.github.io/package/ https://r-forge.r-project.org/projects/test/ http://google.ru https://gitlab.com/r-packages/behaviorchange

cat(cff_create(file)$url)
#> https://test.github.io/package/

cat(cff_create(file)$`repository-code`)
#> https://github.com/test/package

cff_create(file)$identifiers
#> - type: url
#>   value: https://r-forge.r-project.org/projects/test/
#> - type: url
#>   value: http://google.ru
#> - type: url
#>   value: https://gitlab.com/r-packages/behaviorchange

Back to summary.

keywords

This key is extracted from the DESCRIPTION file. The keywords should appear in the DESCRIPTION as:

...
X-schema.org-keywords: keyword1, keyword2, keyword3
Example

# A DESCRIPTION file without keywords
nokeywords <- system.file("examples/DESCRIPTION_basic", package = "cffr")
tmp2 <- tempfile("DESCRIPTION")

# Create a temporary file
file.copy(nokeywords, tmp2)
#> [1] TRUE


pkgnokeywords <- desc::desc(tmp2)
cffnokeywords <- cff_create(tmp2)

# Won't appear
cat(cffnokeywords$keywords)

pkgnokeywords
#> Type: Package
#> Package: basicdesc
#> Title: A Basic Description
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: A very basic description. Should parse without problems.
#> License: GPL-3
#> URL: https://github.com/basic/package, https://basic.github.io/package
#> BugReports: https://github.com/basic/package/issues
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000

# Adding Keywords

desc::desc_set("X-schema.org-keywords", "keyword1, keyword2, keyword3", file = tmp2)
#> Type: Package
#> Package: basicdesc
#> Title: A Basic Description
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: A very basic description. Should parse without problems.
#> License: GPL-3
#> URL: https://github.com/basic/package, https://basic.github.io/package
#> BugReports: https://github.com/basic/package/issues
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000
#> X-schema.org-keywords: keyword1, keyword2, keyword3

cat(cff_create(tmp2)$keywords)
#> keyword1 keyword2 keyword3

Back to summary.

license

This key is extracted from the “License” field of the DESCRIPTION file.

Example

cff_obj <- cff_create("yaml")

cat(cff_obj$license)
#> BSD-3-Clause

pkg <- desc::desc(file.path(find.package("yaml"), "DESCRIPTION"))

cat(pkg$get("License"))
#> BSD_3_clause + file LICENSE

Back to summary.

license-url

This key is not extracted from the metadata of the package. See the description on the Guide to CFF schema v1.2.0.

  • description: The URL of the license text under which the software or dataset is licensed (only for non-standard licenses not included in the SPDX License List).
  • usage:

    yaml license-url: "https://obscure-licenses.com?id=1234"

Back to summary.

message

This key is extracted from the DESCRIPTION field, specifically as:

msg <- paste0(
  'To cite package "',
  "NAME_OF_THE_PACKAGE",
  '" in publications use:'
)
Example

cat(cff_create("jsonlite")$message)
#> To cite package "jsonlite" in publications use:

Back to summary.

preferred-citation

This key is extracted from the CITATION file. If several references are provided, it would select the first citation as the “preferred-citation” and the rest of them as references.

Example

cffobj <- cff_create("rmarkdown")

cffobj$`preferred-citation`
#> type: manual
#> title: 'rmarkdown: Dynamic Documents for R'
#> authors:
#> - family-names: Allaire
#>   given-names: JJ
#> - family-names: Xie
#>   given-names: Yihui
#> - family-names: McPherson
#>   given-names: Jonathan
#> - family-names: Luraschi
#>   given-names: Javier
#> - family-names: Ushey
#>   given-names: Kevin
#> - family-names: Atkins
#>   given-names: Aron
#> - family-names: Wickham
#>   given-names: Hadley
#> - family-names: Cheng
#>   given-names: Joe
#> - family-names: Chang
#>   given-names: Winston
#> - family-names: Iannone
#>   given-names: Richard
#> year: '2021'
#> url: https://github.com/rstudio/rmarkdown

citation("rmarkdown")[1]
#> 
#>   JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi
#>   and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and
#>   Winston Chang and Richard Iannone (2021). rmarkdown: Dynamic
#>   Documents for R. R package version 2.11. URL
#>   https://rmarkdown.rstudio.com.
#> 
#> A BibTeX entry for LaTeX users is
#> 
#>   @Manual{,
#>     title = {rmarkdown: Dynamic Documents for R},
#>     author = {JJ Allaire and Yihui Xie and Jonathan McPherson and Javier Luraschi and Kevin Ushey and Aron Atkins and Hadley Wickham and Joe Cheng and Winston Chang and Richard Iannone},
#>     year = {2021},
#>     note = {R package version 2.11},
#>     url = {https://github.com/rstudio/rmarkdown},
#>   }

Back to summary.

references

This key is extracted from the CITATION file if several references are provided. The first citation is considered as the preferred-citation and the rest of them as “references.”

Example

cffobj <- cff_create("rmarkdown")

cffobj$references
#> - type: book
#>   title: 'R Markdown: The Definitive Guide'
#>   authors:
#>   - family-names: Xie
#>     given-names: Yihui
#>   - family-names: Allaire
#>     given-names: J.J.
#>   - family-names: Grolemund
#>     given-names: Garrett
#>   publisher:
#>     name: Chapman and Hall/CRC
#>   year: '2018'
#>   url: https://bookdown.org/yihui/rmarkdown
#> - type: book
#>   title: R Markdown Cookbook
#>   authors:
#>   - family-names: Xie
#>     given-names: Yihui
#>   - family-names: Dervieux
#>     given-names: Christophe
#>   - family-names: Riederer
#>     given-names: Emily
#>   publisher:
#>     name: Chapman and Hall/CRC
#>   year: '2020'
#>   url: https://bookdown.org/yihui/rmarkdown-cookbook

citation("rmarkdown")[-1]
#> 
#>   Yihui Xie and J.J. Allaire and Garrett Grolemund (2018). R Markdown:
#>   The Definitive Guide. Chapman and Hall/CRC. ISBN 9781138359338. URL
#>   https://bookdown.org/yihui/rmarkdown.
#> 
#>   Yihui Xie and Christophe Dervieux and Emily Riederer (2020). R
#>   Markdown Cookbook. Chapman and Hall/CRC. ISBN 9780367563837. URL
#>   https://bookdown.org/yihui/rmarkdown-cookbook.
#> 
#> To see these entries in BibTeX format, use 'print(<citation>,
#> bibtex=TRUE)', 'toBibtex(.)', or set
#> 'options(citation.bibtex.max=999)'.

Back to summary.

repository

This key is extracted from the “Repository” field of the DESCRIPTION file. Usually, this field is auto-populated when a package is hosted on a repo (like CRAN or the r-universe). For packages without this field on the DESCRIPTION (that is the typical case for an in-development package), cffr would try to search the package on any of the default repositories specified on options("repos").

In the case of Bioconductor packages, those are identified if a “biocViews” is present on the DESCRIPTION file.

If cffr detects that the package is available on CRAN, it would return the canonical url form of the package (i.e. https://CRAN.R-project.org/package=jsonlite).

Example

# Installed package

inst <- cff_create("jsonlite")

cat(inst$repository)
#> https://CRAN.R-project.org/package=jsonlite

# Demo file downloaded from the r-universe

runiv <- system.file("examples/DESCRIPTION_r_universe", package = "cffr")
runiv_cff <- cff_create(runiv)

cat(runiv_cff$repository)
#> https://ropensci.r-universe.dev

desc::desc(runiv)$get("Repository")
#>                        Repository 
#> "https://ropensci.r-universe.dev"

# For in development package

norepo <- system.file("examples/DESCRIPTION_basic", package = "cffr")

# No repo
norepo_cff <- cff_create(norepo)

cat(norepo_cff[["repository"]])

# Change the name to a known package on CRAN: ggplot2

tmp <- tempfile("DESCRIPTION")
file.copy(norepo, tmp)
#> [1] TRUE


# Change name
desc::desc_set("Package", "ggplot2", file = tmp)
#> Type: Package
#> Package: ggplot2
#> Title: A Basic Description
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: A very basic description. Should parse without problems.
#> License: GPL-3
#> URL: https://github.com/basic/package, https://basic.github.io/package
#> BugReports: https://github.com/basic/package/issues
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000

cat(cff_create(tmp)[["repository"]])
#> https://CRAN.R-project.org/package=ggplot2

# Show what happens if another repo is set

# Save original config
orig_options <- options()
getOption("repos")
#>     CRAN 
#> "@CRAN@"


# Set new repos
options(repos = c(
  tidyverse = "https://tidyverse.r-universe.dev",
  CRAN = "https://cloud.r-project.org"
))

# Load again the library
# Repos are evaluated on load
unloadNamespace("cffr")
library(cffr)


cat(cff_create(tmp)[["repository"]])
#> https://tidyverse.r-universe.dev/

# Now it is the tidyverse repo, due to our new config!

# Reset original config
options(orig_options)
getOption("repos")
#>     CRAN 
#> "@CRAN@"

Back to summary.

repository-artifact

This key is not extracted from the metadata of the package. See the description on the Guide to CFF schema v1.2.0.

  • description: The URL of the work in a build artifact/binary repository (when the work is software).

  • usage:

    repository-artifact: "https://search.maven.org/artifact/org.corpus-tools/cff-maven-plugin/0.4.0/maven-plugin"

Back to summary.

repository-code

This key is extracted from the “BugReports” or “URL” fields on the DESCRIPTION file. cffr tries to identify the url of the source on the following repositories:

Example

# Installed package on GitHub

cff_create("jsonlite")$`repository-code`
#> [1] "https://github.com/jeroen/jsonlite"



# GitLab

gitlab <- system.file("examples/DESCRIPTION_gitlab", package = "cffr")

cat(cff_create(gitlab)$`repository-code`)
#> https://gitlab.com/ninijay/methoden


# Check

desc::desc(gitlab)
#> Type: Package
#> Package: codemetar
#> Title: Generate 'CodeMeta' Metadata for R Packages
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Carl Boettiger <cboettig@gmail.com> [aut, cre, cph] (<https://orcid.org/0000-0002-1642-628X>)
#>     * Anna Krystalli [rev, ctb] (<https://orcid.org/0000-0002-2378-4915>)
#>     * Toph Allen [rev] (<https://orcid.org/0000-0003-4580-091X>)
#>     * Maëlle Salmon [ctb, aut] (<https://orcid.org/0000-0002-2815-0399>)
#>     * rOpenSci [fnd] (https://ropensci.org/)
#>     * Katrin Leinweber [ctb]
#>     * Noam Ross [ctb]
#>     * Arfon Smith [ctb]
#> Description: The 'Codemeta' Project defines a 'JSON-LD' format for
#>     describing software metadata, as detailed at
#>     <https://codemeta.github.io>. This package provides utilities to
#>     generate, parse, and modify 'codemeta.json' files automatically for R
#>     packages, as well as tools and examples for working with
#>     'codemeta.json' 'JSON-LD' more generally.
#> License: GPL-3
#> URL: https://gitlab.com/ninijay/methoden,
#>     https://ropensci.github.io/codemetar
#> BugReports: https://gitlab.com/ninijay/methoden/-/issues
#> Depends:
#>     R (>= 3.0.0)
#> Imports:
#>     crul,
#>     desc,
#>     devtools,
#>     gh,
#>     git2r,
#>     jsonld,
#>     jsonlite (>= 1.3),
#>     memoise,
#>     methods,
#>     purrr,
#>     readr,
#>     sessioninfo,
#>     stats,
#>     stringi,
#>     stringr,
#>     tibble,
#>     usethis,
#>     whisker
#> Suggests:
#>     covr,
#>     dplyr (>= 0.7.0),
#>     jsonvalidate,
#>     knitr,
#>     magrittr,
#>     printr,
#>     rmarkdown,
#>     testthat,
#>     xml2
#> VignetteBuilder:
#>     knitr
#> Encoding: UTF-8
#> LazyData: true
#> RoxygenNote: 6.0.1.9000
#> X-schema.org-isPartOf: https://ropensci.org
#> X-schema.org-keywords: metadata, codemeta, ropensci, citation, credit,
#>     linked-data

Back to summary.

title

This key is extracted from the “Description” field of the DESCRIPTION file.

title <- paste0(
  "NAME_OF_THE_PACKAGE",
  ": ",
  "TITLE_OF_THE_PACKAGE"
)
Example

# Installed package

cat(cff_create("testthat")$title)
#> testthat: Unit Testing for R

Back to summary.

type

Fixed value equal to “software.” The other possible value is “dataset.” See the description on the Guide to CFF schema v1.2.0.

Back to summary.

url

This key is extracted from the “BugReports” or “URL” fields on the DESCRIPTION file. It corresponds to the first url that is different to repository-code.

Example

# Many urls
manyurls <- system.file("examples/DESCRIPTION_many_urls", package = "cffr")

cat(cff_create(manyurls)$url)
#> https://test.github.io/package/

# Check

desc::desc(manyurls)
#> Type: Package
#> Package: manyurls
#> Title: A lot of urls
#> Version: 0.1.6
#> Authors@R (parsed):
#>     * Marc Basic <marcbasic@gmail.com> [aut, cre, cph]
#> Description: This package has many urls. Specifically, 1 Bug Reports and 6
#>     URLs. Expected is to have 1 repository-code, 1 url and 3 URLs, since
#>     there is 1 duplicate and 1 invalid url.
#> License: GPL-3
#> URL: https://github.com/test/package, https://test.github.io/package/,
#>     https://r-forge.r-project.org/projects/test/, http://google.ru,
#>     https://gitlab.com/r-packages/behaviorchange, this.is.not.an.url
#> BugReports: https://github.com/test/package/issues
#> Encoding: UTF-8

Back to summary.

version

This key is extracted from the “Version” field on the DESCRIPTION file.


# Should be (>= 3.0.0)
cat(cff_create("testthat")$version)
#> 3.1.0

Back to summary.

References

Druskat, Stephan, Jurriaan H. Spaaks, Neil Chue Hong, Robert Haines, James Baker, Spencer Bliven, Egon Willighagen, David Pérez-Suárez, and Alexander Konovalov. 2021. Citation File Format.” https://doi.org/10.5281/zenodo.5171937.