Type: | Package |
Title: | Citations for 'Knitr' Markdown Files |
Version: | 1.0.12 |
Description: | Provides the ability to create dynamic citations in which the bibliographic information is pulled from the web rather than having to be entered into a local database such as 'bibtex' ahead of time. The package is primarily aimed at authoring in the R 'markdown' format, and can provide outputs for web-based authoring such as linked text for inline citations. Cite using a 'DOI', URL, or 'bibtex' file key. See the package URL for details. |
URL: | https://github.com/cboettig/knitcitations |
BugReports: | https://github.com/cboettig/knitcitations/issues |
License: | MIT + file LICENSE |
VignetteBuilder: | knitr |
Depends: | R (≥ 3.0) |
Imports: | RefManageR (≥ 0.8.2), digest, httr (≥ 0.3), methods, utils |
Suggests: | testthat, knitr (≥ 1.6), rmarkdown |
RoxygenNote: | 7.1.1 |
NeedsCompilation: | no |
Packaged: | 2021-01-08 17:07:39 UTC; cboettig |
Author: | Carl Boettiger |
Maintainer: | Carl Boettiger <cboettig@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2021-01-10 15:40:09 UTC |
get the full metadata for a citation / bibliographic object
Description
get the full metadata for a citation / bibliographic object
Usage
bib_metadata(x, BibEntry = TRUE, ...)
Arguments
x |
a query or citation identifer, as in citep/citet, except that it must be a single query, not a list of multiple queries. |
BibEntry |
logical. Coerce to RefManageR's BibEntry type? |
... |
additional arguments to query (see RCrossRef) |
Details
This function is called internally by citet and citep, but is also made available in the namespace for a user wanting to return the full citation object directly.
Value
a BibEntry (or bibentry, if requested) object with the required citation information.
Generate the bibliography
Description
Generate the bibliography
Usage
bibliography(style = "text", ...)
Arguments
style |
see RefManageR::PrintBibliography |
... |
additional arguments passed to PrintBibliography, |
Details
For non-trivial bibliographies, knitcitations recommends authors use pandoc format, and allow pandoc to generate the references list rather than rely on the bibliography() function. Pandoc has rich CSL support using any provided CSL file (see Pandoc documentation for details) and is integrated into recent version of RStudio.
Value
a list of works cited
Examples
citet(citation("httr"))
citet(citation("digest"))
bibliography()
bibliography(sorting = 'ynt') # sort by year, then name, title
bibliography(sorting = 'ydnt') # sort by year, descending, then name, title
cleanbib()
Toggles for various citation options
Description
Toggles for various citation options
Usage
cite_options(
citation_format = "compatibility",
style = "text",
hyperlink = FALSE,
cite.style = "authoryear",
super = FALSE,
max.names = 4,
longnamesfirst = FALSE,
check.entries = FALSE,
...
)
Arguments
citation_format |
'pandoc', 'compatibility' (with version 0.5 or earlier), or 'text' |
style |
plain "text" style (default) inline citations, "markdown" style or or html style links to the hyperlink |
hyperlink |
Either logical (FALSE), or link "to.doc" (by DOI if available, otherwise to URL), or link "to.bib" section. |
cite.style |
Should inline textual citations use "authoryear", "numeric", or "authortitle" format? |
super |
logical, should numeric cite.style be a superscript? |
max.names |
numeric, maximum number of names to list before adding "et al.". |
longnamesfirst |
logical. Should all authors be listed the first time a citation is used (rather than obeying max.names?) |
check.entries |
logical. Should error if any 'required' bibtex field is missing? Default FALSE |
... |
additional arguments to BibOptions |
Value
updates the option specified for the duration of the session.
citep - inline parenthetical citation
Description
Generate an inline parenthetical citation
Usage
citep(x, ...)
Arguments
x |
a citation query, or list of queries for multiple citations. See details and examples |
... |
additional arguments for the search or formatting. See details. |
Details
the citation query can be any of: - A bibentry object, - An article or dataset DOI, - The URL to a website such as a scientific journal article page - A path to a PDF file (will attempt to extract citation info) - A search query string, such as part of the article title, year, or journal (Queries CrossRef) - The bibkey to anything that has already been cited. knitcitations will attempt to find the most complete citation information based on the information specified. In some cases that information may be incomplete. When using search queries rather than an exact reference (such as URL, DOI, pdf, or bibkey) the desired article may not be found or many not be uniquely determined by the string. The most relevant search result is returned, so consider refining search terms as necessary. See examples.
Value
Format of the parenthetical citation will depend on configuration.
Unless citation_format = "pandoc", formatting is handled by
Citep
. See the arguments to Citep for details.
knitcitations will automatically track what has been cited during the
active R session until the citation log is reset.
See Also
Citep
for more details on the
parenthetical citation generation. citet
for generating
inline text citations.
Examples
# Cite an R package using the 'bibentry' object
citep(citation("httr"))
citet - inline text citation
Description
Generate an inline text citation
Usage
citet(x, ...)
Arguments
x |
a citation query, or list of queries for multiple citations. See details and examples |
... |
additional arguments for the search or formatting. See details. |
Details
the citation query can be any of: - A bibentry object, - An article or dataset DOI, - The URL to a website such as a scientific journal article page - A path to a PDF file (will attempt to extract citation info) - A search query string, such as part of the article title, year, or journal (Queries CrossRef) - The bibkey to anything that has already been cited. knitcitations will attempt to find the most complete citation information based on the information specified. In some cases that information may be incomplete. When using search queries rather than an exact reference (such as URL, DOI, pdf, or bibkey) the desired article may not be found or many not be uniquely determined by the string. The most relevant search result is returned, so consider refining search terms as necessary. See examples.
Value
Format of the text citation will depend on configuration. Unless
citation_format = "pandoc", formatting is handled by
Citet
. See the arguments to Citet for details.
knitcitations will automatically track what has been cited during the
active R session until the citation log is reset.
See Also
Citep
for more details on the inline text
citation generation. citep
for generating parenthetical
citations.
Examples
# Cite an R package using the 'bibentry' object
citet(citation("httr"))
cleanbib
Description
Clean the log of works cited so far.
Usage
cleanbib()
Value
Removes log cache, returns invisible 'NULL'
greycite citation method
Description
Grab citation data using the greycite API
Usage
greycite(url, format = c("bib", "json"))
Arguments
url |
the website URL |
format |
have greycite return data in bib (bibtex) or json format? |
Value
a bibentry class object
read.bibtex
Description
read.bibtex
Usage
read.bibtex(file, .Encoding = "UTF-8", check = FALSE)
Arguments
file |
string; bib file to parse. |
.Encoding |
encoding |
check |
error, warn, or logical FALSE. What action should be taken if an entry is missing required fields? FALSE means no checking is done, warn means entry is added with an error. error means the entry will not be added. See BibOptions. |
Value
Returns the bib object
record as cited
Description
adds a BibEntry object to the works cited list even if not cited with a call to citep/citet
Usage
record_as_cited(entry)
Arguments
entry |
a BibEntry object (or something that can be coerced to one, like bibentry) |
Value
Adds the object to the citation list, with a BibTex citation key that does not duplicate any that are already in the record. Invisibly returns the bibentry object.
write a bibtex file
Description
write a bibtex file
Usage
write.bibtex(entry = NULL, file = "knitcitations.bib", append = FALSE, ...)
Arguments
entry |
a 'bibentry' object or list of bibentry objects. If NULL, writes all that have currently been cited. |
file |
output bibtex file. Will automatically append '.bib' if not added. if 'NULL' will use stdout. |
append |
a logical indicating that bibtex entries be added the the file. If FALSE (default), the file is overwritten. |
... |
additional arguments to WriteBib |
Value
a list of citation information, invisibly
See Also
read.bib citep citet
Examples
tmp <- tempfile(fileext=".bib")
write.bibtex(c(citation("knitr"),
citation("knitcitations"),
citation("httr")),
file = tmp)
bib <- read.bibtex(tmp)