سؤال

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!

هل كانت مفيدة؟

المحلول 2

The CITATION file should be in the inst directory. See the official documentation for details of what should be in the file.

نصائح أخرى

CITATION template can be created automatically with

usethis::use_citation()

Once the file is created, you only need to fill in the gaps.

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().

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top