Reputation: 10956
I am building my R package using Roxygen2
and devtools
, and I would like to add some citation information in my R
codes (i.e. I hope to write in a .R
file from which the citations can be auto-generated). The ultimate goal is to display, once I run the command citation(MyPkgName)
, the citations of the R package as well as the citation (preferrably with BibTeX entry) of the paper I submit. Is there a way to do that using devtools
? Thanks!
Upvotes: 17
Views: 5881
Reputation: 3121
A file called "CITATION" needs to be created in the directory "yourPackage/inst/". The file CITATION
can be created automatically with
usethis::use_citation()
This file will contain an unfilled template with blank fields for citation information (e.g., author, journal, year, etc.) You need to fill in the gaps.
Upvotes: 23
Reputation: 2684
Another way to include citation in your package is during attach time (e.g. when using library()
).
You can do so using the function .onAttach()
(it could go in a zzz.R
file, as suggested in Hadley's R Packages book).
One example, would be:
.onAttach<-function(libname, pkgname){
packageStartupMessage('Please cite this paper!')
}
But you can easily search for other examples in the net, as this one including a call to citation()
.
Upvotes: 2
Reputation: 60462
The CITATION
file should be in the inst
directory. See the official documentation for details of what should be in the file.
Upvotes: 19