yml_reference()
creates YAML fields for references to be used in citation.
reference()
is a simple function to add references to yml_reference()
. The
easiest way to add references to an R Markdown file is to use a bibliography
file, such as .bib, in the bibliography
field (see yml_citations()
). For
documents with very few references, however, it might be useful to make the
references self-contained in the YAML. yml_reference()
can also transform to
YAML bibentry
and citation
objects created bybibentry()
and
citation()
. To cite many R packages and convert the references to YAML,
it may be better to use knitr::write_bib()
to write a bibliography file and
convert it with bib2yml()
.
yml_reference(.yml, ..., .bibentry = NULL)
reference(id = NULL, ...)
a yml
object created by yml()
, as_yml()
, or returned by
a yml_*()
function
Fields relevant to the citation (e.g. bibtex fields)
An object created by bibentry()
or citation()
. Note that
this requires pandoc-citeproc to be installed.
a character vector to use as the reference ID
a yml
object
Other yml:
asis_yaml_output()
,
bib2yml()
,
draw_yml_tree()
,
has_field()
,
read_json()
,
use_yml_defaults()
,
use_yml_file()
,
use_yml()
,
yml_author()
,
yml_blogdown_opts()
,
yml_bookdown_opts()
,
yml_citations()
,
yml_clean()
,
yml_distill_opts()
,
yml_latex_opts()
,
yml_output()
,
yml_pagedown_opts()
,
yml_params()
,
yml_pkgdown()
,
yml_replace()
,
yml_resource_files()
,
yml_rsconnect_email()
,
yml_rticles_opts()
,
yml_runtime()
,
yml_site_opts()
,
yml_toc()
,
yml_vignette()
Other citations:
bib2yml()
,
yml_citations()
ref <- reference(
id = "fenner2012a",
title = "One-click science marketing",
author = list(
family = "Fenner",
given = "Martin"
),
`container-title` = "Nature Materials",
volume = 11L,
URL = "https://doi.org/10.1038/nmat3283",
DOI = "10.1038/nmat3283",
issue = 4L,
publisher = "Nature Publishing Group",
page = "261-263",
type = "article-journal",
issued = list(
year = 2012,
month = 3
)
)
yml() %>%
yml_reference(ref)
#> ---
#> date: '`r format(Sys.Date())`'
#> reference:
#> - id: fenner2012a
#> title: One-click science marketing
#> author:
#> family: Fenner
#> given: Martin
#> container-title: Nature Materials
#> volume: 11
#> URL: https://doi.org/10.1038/nmat3283
#> DOI: 10.1038/nmat3283
#> issue: 4
#> publisher: Nature Publishing Group
#> page: 261-263
#> type: article-journal
#> issued:
#> year: 2012.0
#> month: 3.0
#> ---
#>
# from ?bibentry
bref <- c(
bibentry(
bibtype = "Manual",
title = "boot: Bootstrap R (S-PLUS) Functions",
author = c(
person("Angelo", "Canty", role = "aut",
comment = "S original"),
person(c("Brian", "D."), "Ripley", role = c("aut", "trl", "cre"),
comment = "R port, author of parallel support",
email = "ripley@stats.ox.ac.uk")
),
year = "2012",
note = "R package version 1.3-4",
url = "https://CRAN.R-project.org/package=boot",
key = "boot-package"
),
bibentry(
bibtype = "Book",
title = "Bootstrap Methods and Their Applications",
author = as.person("Anthony C. Davison [aut], David V. Hinkley [aut]"),
year = "1997",
publisher = "Cambridge University Press",
address = "Cambridge",
isbn = "0-521-57391-2",
url = "http://statwww.epfl.ch/davison/BMA/",
key = "boot-book"
)
)
# \donttest{
# requires pandoc-citeproc to be installed
yml() %>%
yml_reference(.bibentry = bref)
#> ---
#> date: '`r format(Sys.Date())`'
#> ---
#>
yml() %>%
yml_reference(.bibentry = citation("purrr"))
#> ---
#> date: '`r format(Sys.Date())`'
#> ---
#>
# }