5

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?

2 Answers 2

6

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" 
Sign up to request clarification or add additional context in comments.

Comments

1

Anytime an R user applies the function, they will get the same result by definition of the function itself. You have to copy the output result (bib entry) or write it to a file and there you can choose and the bibkey to any bibkey you want.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.