utils::citation() offers the option auto=(NULL|TRUE) to obtain the
citations for a package from the package
DESCRIPTION file or a CITATION file, as described below:
|auto|
a logical indicating whether the default citation auto-generated from
the package 'DESCRIPTION' metadata should be used or not, or |NULL|
(default), indicating that a 'CITATION' file is used if it exists, or an
object of class |"packageDescription
<http://127.0.0.1:11936/library/utils/help/packageDescription>"| with
package metadata (see below).
This presents a problem when citation() is used in functions such as
bibtex::write.bib() and
knitr::write_bib(), because the "base" package is treated specially in
citation() and does not
allow auto=TRUE
> citation("base",auto=TRUE)
Error in citation("base", auto = TRUE) :
broken installation, no CITATION file in the base package.
>
This is a strange and misleading message, since the base package,
presumably by design
has no CITATION file. It requires a workaround in functions like
knitr::write_bib when given
a list of packages,
bib = sapply(x, function(pkg) {
cite = citation(pkg, auto = if (pkg == "base")
NULL
else TRUE)
entry = toBibtex(cite)
entry[1] = sub("\\{,$", sprintf("{R-%s,", pkg),
entry[1])
gsub("", "", entry)
}, simplify = FALSE)
Is there some reason why citation() can't simply ignore auto=TRUE
(perhaps with a message)
for the base package?
--
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street Web: http://www.datavis.ca
Toronto, ONT M3J 1P3 CANADA
[[alternative HTML version deleted]]