This is the core function of the package and likely to be the only one you would need when developing a package.
This function writes out a CITATION.cff
file for a given package. This
function is basically a wrapper around cff_create()
to both create the
cff
object and writes it out to a YAML-formatted file in one command.
Arguments
- x
The source that would be used for generating the
CITATION.cff
file. It could be:A missing value. That would retrieve the DESCRIPTION file on your in-development package.
A
cff
object,The name of an installed package (
"jsonlite"
), orPath to a DESCRIPTION file (
"*/DESCRIPTION*"
).
- outfile
The name and path of the
CITATION.cff
to be created.- keys
List of additional keys to add to the
cff
object. Seecff_create()
for details and examples.- cff_version
The Citation File Format schema version that the
CITATION.cff
file adheres to for providing the citation metadata.- gh_keywords
Logical
TRUE/FALSE
. If the package is hosted on GitHub, would you like to add the repo topics as keywords?- dependencies
Logical
TRUE/FALSE
. Would you like to add the of your package to thereference
key?- validate
Logical
TRUE/FALSE
. Should the new file be validated usingcff_validate()
?- verbose
Logical
TRUE/FALSE
. OnTRUE
the function would display informative messages.- authors_roles
Roles to be considered as authors of the package when generating the
CITATION.cff
file. See Details oncff_create()
.
Value
A CITATION.cff
file and an (invisible) cff
object.
Details
When creating and writing a CITATION.cff
for the first time, the function
adds "CITATION.cff" to ".Rbuildignore".
See also
Guide to Citation File Format schema version 1.2.0.
Other Core functions:
cff_create()
,
cff_read()
,
cff_validate()
Examples
# \donttest{
tmpfile <- tempfile(fileext = ".cff")
cff_obj <- cff_write("jsonlite", outfile = tmpfile)
#> ✔ /tmp/RtmpxOFwT9/file48dfc580a2.cff generated
#> ══ Validating cff ══════════════════════════════════════════════════════════════
#> ✔ Congratulations! /tmp/RtmpxOFwT9/file48dfc580a2.cff is valid
cff_obj
#> cff-version: 1.2.0
#> message: 'To cite package "jsonlite" in publications use:'
#> type: software
#> license: MIT
#> title: 'jsonlite: A Simple and Robust JSON Parser and Generator for R'
#> version: 1.8.7
#> abstract: A reasonably fast JSON parser and generator, optimized for statistical data
#> and the web. Offers simple, flexible tools for working with JSON in R, and is particularly
#> powerful for building pipelines and interacting with a web API. The implementation
#> is based on the mapping described in the vignette (Ooms, 2014). In addition to converting
#> JSON data from/to R objects, 'jsonlite' contains functions to stream, validate,
#> and prettify JSON data. The unit tests included with the package verify that all
#> edge cases are encoded and decoded consistently for use with dynamic data in systems
#> and applications.
#> authors:
#> - family-names: Ooms
#> given-names: Jeroen
#> email: [email protected]
#> orcid: https://orcid.org/0000-0002-4035-0289
#> preferred-citation:
#> type: article
#> title: 'The jsonlite Package: A Practical and Consistent Mapping Between JSON Data
#> and R Objects'
#> authors:
#> - family-names: Ooms
#> given-names: Jeroen
#> email: [email protected]
#> orcid: https://orcid.org/0000-0002-4035-0289
#> journal: arXiv:1403.2805 [stat.CO]
#> year: '2014'
#> url: https://arxiv.org/abs/1403.2805
#> repository: https://CRAN.R-project.org/package=jsonlite
#> repository-code: https://github.com/jeroen/jsonlite
#> url: https://jeroen.r-universe.dev/jsonlite
#> date-released: '2023-06-29'
#> contact:
#> - family-names: Ooms
#> given-names: Jeroen
#> email: [email protected]
#> orcid: https://orcid.org/0000-0002-4035-0289
#> keywords:
#> - json
#> - parser
#> - r
#> - rstats
#> references:
#> - type: software
#> title: methods
#> abstract: 'R: A Language and Environment for Statistical Computing'
#> notes: Depends
#> authors:
#> - name: R Core Team
#> location:
#> name: Vienna, Austria
#> year: '2023'
#> institution:
#> name: R Foundation for Statistical Computing
#> - type: software
#> title: httr
#> abstract: 'httr: Tools for Working with URLs and HTTP'
#> notes: Suggests
#> url: https://httr.r-lib.org/
#> repository: https://CRAN.R-project.org/package=httr
#> authors:
#> - family-names: Wickham
#> given-names: Hadley
#> email: [email protected]
#> year: '2023'
#> - type: software
#> title: vctrs
#> abstract: 'vctrs: Vector Helpers'
#> notes: Suggests
#> url: https://vctrs.r-lib.org/
#> repository: https://CRAN.R-project.org/package=vctrs
#> authors:
#> - family-names: Wickham
#> given-names: Hadley
#> email: [email protected]
#> - family-names: Henry
#> given-names: Lionel
#> email: [email protected]
#> - family-names: Vaughan
#> given-names: Davis
#> email: [email protected]
#> year: '2023'
#> - type: software
#> title: testthat
#> abstract: 'testthat: Unit Testing for R'
#> notes: Suggests
#> url: https://testthat.r-lib.org
#> repository: https://CRAN.R-project.org/package=testthat
#> authors:
#> - family-names: Wickham
#> given-names: Hadley
#> email: [email protected]
#> year: '2023'
#> - type: software
#> title: knitr
#> abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R'
#> notes: Suggests
#> url: https://yihui.org/knitr/
#> repository: https://CRAN.R-project.org/package=knitr
#> authors:
#> - family-names: Xie
#> given-names: Yihui
#> email: [email protected]
#> orcid: https://orcid.org/0000-0003-0645-5666
#> year: '2023'
#> - type: software
#> title: rmarkdown
#> abstract: 'rmarkdown: Dynamic Documents for R'
#> notes: Suggests
#> url: https://pkgs.rstudio.com/rmarkdown/
#> repository: https://CRAN.R-project.org/package=rmarkdown
#> authors:
#> - family-names: Allaire
#> given-names: JJ
#> email: [email protected]
#> - family-names: Xie
#> given-names: Yihui
#> email: [email protected]
#> orcid: https://orcid.org/0000-0003-0645-5666
#> - family-names: Dervieux
#> given-names: Christophe
#> email: [email protected]
#> orcid: https://orcid.org/0000-0003-4474-2498
#> - family-names: McPherson
#> given-names: Jonathan
#> email: [email protected]
#> - family-names: Luraschi
#> given-names: Javier
#> - family-names: Ushey
#> given-names: Kevin
#> email: [email protected]
#> - family-names: Atkins
#> given-names: Aron
#> email: [email protected]
#> - family-names: Wickham
#> given-names: Hadley
#> email: [email protected]
#> - family-names: Cheng
#> given-names: Joe
#> email: [email protected]
#> - family-names: Chang
#> given-names: Winston
#> email: [email protected]
#> - family-names: Iannone
#> given-names: Richard
#> email: [email protected]
#> orcid: https://orcid.org/0000-0003-3925-190X
#> year: '2023'
#> identifiers:
#> - type: url
#> value: https://arxiv.org/abs/1403.2805
# Force clean-up
file.remove(tmpfile)
#> [1] TRUE
# }