Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R missing bib key in citation() output

Tags:

r

I am using citation() to automatically get the bib entries for R packages. However, its output does not have a key.

Example:

utils:::print.bibentry(citation(), style = "Bibtex")

Output:

@Manual{,
  title = {R: A Language and Environment for Statistical Computing},
  author = {{R Core Team}},
  organization = {R Foundation for Statistical Computing},
  address = {Vienna, Austria},
  year = {2017},
  url = {https://www.R-project.org/},
}

I would like something like this:

@Manual{mykey999,
  title = {R: A Language and Environment for Statistical Computing},
  author = {{R Core Team}},
  organization = {R Foundation for Statistical Computing},
  address = {Vienna, Austria},
  year = {2017},
  url = {https://www.R-project.org/},
}

I've tried the same command with the "key" argument but it changes nothing:

utils:::print.bibentry(citation(), style = "Bibtex", key= "mykey0")

Any idea?

like image 236
GP. Avatar asked Sep 12 '17 15:09

GP.


1 Answers

You can do

z = citation()
z$key = "Hullo"
print(z, "Bibtex")

which gives

@Manual{Hullo,
  title = {R: A Language and Environment for Statistical Computing},
  author = {{R Core Team}},
  organization = {R Foundation for Statistical Computing},
  address = {Vienna, Austria},
  year = {2017},
  url = {https://www.R-project.org/},
}

Alternately, there's the silly one-liner:

print(`$<-`(citation(), key, "Hullo"), "Bibtex")

I guess using ::: to access print (as in the OP) is overkill here. If you like looking at internals, though, maybe have a gander at utils:::`$<-.bibentry`. From there, you can see that expected assignments are to...

utils:::bibentry_attribute_names
# [1] "bibtype"     "textVersion" "header"      "footer"      "key"   
like image 151
Frank Avatar answered Sep 28 '22 18:09

Frank