print_refs | R Documentation |
.bib
Entries as Referencesprint_refs()
is a convenience function I found and
edited that will allow a user to print and format .bib
entries as if they
were references. This function is useful if you want to load a .bib
entry or set of entries and print them in the middle of a document in
R Markdown.
print_refs(
bib,
csl = "american-political-science-association.csl",
toformat = "markdown_strict",
cslrepo = "https://raw.githubusercontent.com/citation-style-language/styles/master",
spit_out = TRUE,
delete_after = TRUE
)
bib |
a valid |
csl |
a CSL file, matching one available on the Github repository, that the user wants to format the references. Default is "american-political-science-association.csl". |
toformat |
the output wanted by the user. Default is "markdown_strict". |
cslrepo |
a directory of CSL files. Defaults to the one on Github. |
spit_out |
logical, defaults to TRUE. If TRUE, wraps ("spits out") formatted citations in a |
delete_after |
logical, defaults to TRUE. If TRUE, deletes CSL file when it's done. If FALSE, retains CSL for (potential) future use. |
print_refs()
assumes an active internet connection in the absence of the appropriate CSL file in the
working directory. The citation style language (CSL) file supplied by the user must match a file in the
massive Github repository of CSL files. Users interested in potential outputs should read more about Pandoc (https://pandoc.org/MANUAL.html).
The Github repository of CSL files is available here: https://github.com/citation-style-language/styles.
print_refs()
takes a .bib
entry and returns the
requested formatted reference or references from it.
example <- "@Book{vasquez2009twp, Title = {The War Puzzle Revisited},
Author = {Vasquez, John A}, Publisher = {New York, NY: Cambridge University Press},
Year = {2009}}"
print_refs(example)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.