cite {utils}R Documentation

Cite a Bibliography Entry


Cite a bibentry object in text. The cite() function uses the cite() function from the default bibstyle if present, or citeNatbib() if not. citeNatbib() uses a style similar to that used by the LaTeX package natbib.


cite(keys, bib, ...)
citeNatbib(keys, bib, textual = FALSE, before = NULL, after = NULL,
           mode = c("authoryear", "numbers", "super"),
           abbreviate = TRUE, longnamesfirst = TRUE,
           bibpunct = c("(", ")", ";", "a", "", ","), previous)



A character vector of keys of entries to cite. May contain multiple keys in a single entry, separated by commas.


A "bibentry" object containing the list of documents in which to find the keys.


Additional arguments to pass to the cite() function for the default style.


Produce a “textual” style of citation, i.e. what \citet would produce in LaTeX.


Optional text to display before the citation.


Optional text to display after the citation.


The “mode” of citation.


Whether to abbreviate long author lists.


If abbreviate == TRUE, whether to leave the first citation long.


A vector of punctuation to use in the citation, as used in natbib. See the Details section.


A list of keys that have been previously cited, to be used when abbreviate == TRUE and longnamesfirst == TRUE


Argument names are chosen based on the documentation for the LaTeX natbib package. See that documentation for the interpretation of the bibpunct entries.

The entries in bibpunct are as follows:

  1. The left delimiter.

  2. The right delimiter.

  3. The separator between references within a citation.

  4. An indicator of the “mode”: "n" for numbers, "s" for superscripts, anything else for author-year.

  5. Punctuation to go between the author and year.

  6. Punctuation to go between years when authorship is suppressed.

Note that if mode is specified, it overrides the mode specification in bibpunct[4]. Partial matching is used for mode.

The defaults for citeNatbib have been chosen to match the JSS style, and by default these are used in cite. See bibstyle for how to set a different default style.


A single element character string is returned, containing the citation.


Duncan Murdoch


## R reference
rref <- bibentry(
   bibtype = "Manual",
   title = "R: A Language and Environment for Statistical Computing",
   author = person("R Core Team"),
   organization = "R Foundation for Statistical Computing",
   address = "Vienna, Austria",
   year = 2013,
   url = "",
   key = "R")

## References for boot package and associated book
bref <- c(
     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 = "")
     year = "2012",
     note = "R package version 1.3-4",
     url = "",
     key = "boot-package"

     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 = "",
     key = "boot-book"

## Combine and cite
refs <- c(rref, bref)
cite("R, boot-package", refs)

## Cite numerically
savestyle <- tools::getBibstyle()
tools::bibstyle("JSSnumbered", .init = TRUE,
         fmtPrefix = function(paper) paste0("[", paper$.index, "]"),
         cite = function(key, bib, ...)
         	citeNatbib(key, bib, mode = "numbers",
         	    bibpunct = c("[", "]", ";", "n", "", ","), ...)
cite("R, boot-package", refs, textual = TRUE)

## restore the old style
tools::bibstyle(savestyle, .default = TRUE)

[Package utils version 3.5.0 Index]