cff_writer {handlr} | R Documentation |
Citation File Format (cff) writer
Description
Citation File Format (cff) writer
Usage
cff_writer(z, path = NULL)
Arguments
z |
an object of class |
path |
a file path or connection; default: |
Details
uses yaml::write_yaml
to write to yaml format that
CFF uses
Value
text if one cff citation or list of many
Converting to CFF from other formats
CFF has required fields that can't be missing. This means that
converting from other citation types to CFF will likely require
adding the required CFF fields manually. Adding fields to a
handl
object is easy: it's really just an R list so add
named elements to it. The required CFF fields are:
cff-version: add
cff_version
message: add
message
version: add
software_version
title: add
title
authors: add
author
date-released: add
date_published
References
CFF format: https://github.com/citation-file-format/citation-file-format
See Also
Other writers:
bibtex_writer()
,
citeproc_writer()
,
codemeta_writer()
,
rdf_xml_writer()
,
ris_writer()
,
schema_org_writer()
Other cff:
cff_reader()
Examples
(z <- system.file('extdata/citation.cff', package = "handlr"))
res <- cff_reader(x = z)
res
unclass(res)
cff_writer(res)
cat(cff_writer(res))
f <- tempfile()
cff_writer(res, f)
readLines(f)
unlink(f)
# convert from a different citation format
## see "Converting to CFF from other formats" above
z <- system.file('extdata/citeproc.json', package = "handlr")
w <- citeproc_reader(x = z)
# cff_writer(w) # fails unless we add required fields
w$cff_version <- "1.1.0"
w$message <- "Please cite the following works when using this software."
w$software_version <- "2.5"
w$title <- "A cool library"
w$date_published <- "2017-12-18"
cff_writer(w)
cat(cff_writer(w))