R 在 citation() 输出中缺少围兜键

标签 r

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

例子:

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

我已经用“key”参数尝试了相同的命令,但它没有任何改变:
utils:::print.bibentry(citation(), style = "Bibtex", key= "mykey0")

任何的想法?

最佳答案

你可以做

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"   

关于R 在 citation() 输出中缺少围兜键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46179997/

相关文章:

excel - 为 xts 应用函数

r - 从 R 访问 S3 存储桶

r - 从 KS 检验中找到最大 D 统计量的位置

r - 如何使用 R 传递字符集和 Firebird 的角色

r - R 中 align_local 函数的错误

r - 在 R 中获取与前一个日期的差异

r - 将字符转换为日期

r - 我可以在 R markdown2 中使用 `hyperref`

r - 具有不等大小组的高效递归随机抽样

function - R 存在函数吗?