gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 18:01:43 24 4
gpt4 key购买 nike

我正在使用 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com