R在citation()输出中丢失了bib键

时间:2017-09-12 15:12:15

标签: r

我正在使用citation()来自动获取R包的bib条目。但是,它的输出没有密钥。

示例:

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

输出:

@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/},
}

我想要这样的事情:

@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/},
}

我用"键"尝试了相同的命令。参数,但它什么都没改变:

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

有什么想法吗?

2 个答案:

答案 0 :(得分:5)

你可以做到

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

给出了

@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/},
}

或者,有一个愚蠢的单行:

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

我想使用:::来访问print(如在OP中)在这里是过度的。但是,如果你喜欢看内幕,可能会对utils:::`$<-.bibentry`感到愤怒。从那里,你可以看到预期的任务是......

utils:::bibentry_attribute_names
# [1] "bibtype"     "textVersion" "header"      "footer"      "key"   

答案 1 :(得分:1)

无论何时R用户应用该函数,它们将通过函数本身的定义得到相同的结果。你必须复制输出结果(bib条目)或将其写入文件,然后你可以选择和你想要的任何bibkey的bibkey。