[R-pkg-devel] [Rd] Making a package CITATION file from BibTeX
Dr Gregory Jefferis
je||er|@ @end|ng |rom mrc-|mb@c@m@@c@uk
Thu May 30 02:31:30 CEST 2019
Dear Achim,
Thank you so much for taking the time to write out a perfect response to
my question. I hope it will soon be available for others to google!
@Inaki: Thank you. You are quite right. I intended to write to
r-package-devel. Achim's reply is still copied below for users of that
list.
All the best,
Greg.
On 29 May 2019, at 23:46, Achim Zeileis wrote:
> On Thu, 30 May 2019, Dr Gregory Jefferis wrote:
>
>> Dear Colleagues,
>>
>> I would like to provide a CITATION file for my package nat.nblast
>> [1].
>>
>> I have the correct citation in BibTeX format [2]. How can I convert
>> this BibTeX to the format needed by R for a package CITATION file (I
>> have a lot of other packages needing citations ...).
>
> (1) You can use read.bib() from the "bibtex" package to read the .bib
> file containing the relevant reference.
>
> (2) This gives you a "bibentry" object that can be turned into the R
> code generating it with format(..., style = "R") from the basic
> "utils" package.
>
> (3) Then you can writeLines() this R code on the console or
> writeLines(..., "CITATION") to a CITATION file.
>
> (4) Optionally you can also include a $header in your bibentry with a
> short introductory sentence. Or if you have multiple references to go
> into the same CITATION you might want to include a $header for each
> and an $mheader for everything.
>
> A worked example is included below. Background information is given
> in: https://doi.org/10.32614/RJ-2012-009
>
> Let's assume that your BibTeX entry [2] is the first entry in a file
> called "my.bib". Then you can do:
>
> ## read first item from BibTeX as "bibentry" object
> b <- bibtex::read.bib("my.bib")[[1]]
>
> ## delete the bib key and add a header for the citation
> b$key <- NULL
> b$header <- "To cite nat.nblast in publications use:"
>
> ## turn the "bibentry" into the R code generating it
> b <- format(b, style = "R")
>
> ## write the R code to the console
> writeLines(b)
>
> bibentry(bibtype = "Article",
> header = "To cite nat.nblast in publications use:",
> author = c(person(given = "Marta",
> family = "Costa"),
> person(given = c("James", "D"),
> family = "Manton"),
> person(given = c("Aaron", "D"),
> family = "Ostrovsky"),
> person(given = "Steffen",
> family = "Prohaska"),
> person(given = c("Gregory", "S", "X", "E"),
> family = "Jefferis")),
> doi = "10.1016/j.neuron.2016.06.012",
> journal = "Neuron",
> month = "Jul",
> number = "2",
> pages = "293-311",
> title = "NBLAST: Rapid, Sensitive Comparison of Neuronal
> Structure and Construction of Neuron Family Databases",
> volume = "91",
> year = "2016")
>
>
>> I think what I need is the opposite of RefManageR::toBiblatex [3].
>> This seems like it should be a common need, so I feel sure I must be
>> missing something, but I can't seem to google up any hints.
>>
>> With many thanks,
>>
>> Greg Jefferis.
>>
>> [1] http://github.com/jefferislab/nat.nblast
>> https://cran.r-project.org/package=nat.nblast
>> [2]
>>
>> @article{Costa:2016aa,
>> Author = {Costa, Marta and Manton, James D and Ostrovsky, Aaron D
>> and Prohaska, Steffen and Jefferis, Gregory S X E},
>> Doi = {10.1016/j.neuron.2016.06.012},
>> Journal = {Neuron},
>> Month = {Jul},
>> Number = {2},
>> Pages = {293-311},
>> Title = {NBLAST: Rapid, Sensitive Comparison of Neuronal Structure
>> and Construction of Neuron Family Databases},
>> Volume = {91},
>> Year = {2016}}
>>
>> [3] https://rdrr.io/github/ropensci/RefManageR/man/toBiblatex.html
>>
>>
>> --
>> Gregory Jefferis
>> Division of Neurobiology
>> MRC Laboratory of Molecular Biology
>> Francis Crick Avenue
>> Cambridge Biomedical Campus
>> Cambridge, CB2 OQH, UK
>>
>> http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
>> http://jefferislab.org
>> http://www.zoo.cam.ac.uk/departments/connectomics
>>
>> ______________________________________________
>> R-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
--
Gregory Jefferis, PhD Tel: +44 1223 267048
Division of Neurobiology
MRC Laboratory of Molecular Biology
Francis Crick Avenue
Cambridge Biomedical Campus
Cambridge, CB2 OQH, UK
http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://jefferislab.org
http://www.zoo.cam.ac.uk/departments/connectomics
More information about the R-package-devel
mailing list