首页 > > > R语言软件包的批量引用
作者:黄天元,复旦大学博士在读,热爱数据科学与开源工具(R),致力于利用数据科学迅速积累行业经验优势和科学知识发现,涉猎内容包括但不限于信息计量、机器学习、数据可视化、应用统计建模、知识图谱等。知乎专栏:R语言数据挖掘。邮箱:huang.tian-yuan@qq.com.欢迎合作交流。
写论文的时候如果用了R的软件包,需要引用,一般直接使用citation()函数可以引用当前版本的R,用citation("package_name")可以引用特定的包。展示如下:
> citation()
To cite R in publications use:
R Core Team (2019). R: A language and environment for statistical computing. R Foundation for
Statistical Computing, Vienna, Austria. URL https://www.R-project.org/.
A BibTeX entry for LaTeX users is
@Manual{,
title = {R: A Language and Environment for Statistical Computing},
author = {{R Core Team}},
organization = {R Foundation for Statistical Computing},
address = {Vienna, Austria},
year = {2019},
url = {https://www.R-project.org/},
}
We have invested a lot of time and effort in creating R, please cite it when using it for data analysis.
See also ‘citation("pkgname")’ for citing R packages.
> citation("tidyverse")
To cite package ‘tidyverse’ in publications use:
Hadley Wickham (2017). tidyverse: Easily Install and Load the 'Tidyverse'. R package version 1.2.1.
https://CRAN.R-project.org/package=tidyverse
A BibTeX entry for LaTeX users is
@Manual{,
title = {tidyverse: Easily Install and Load the 'Tidyverse'},
author = {Hadley Wickham},
year = {2017},
note = {R package version 1.2.1},
url = {https://CRAN.R-project.org/package=tidyverse},
}如果已经在环境中使用了大量的包,则可以用knitr的write_bib函数批量导出,并写出bib格式的文件:
knitr::write_bib(c(
.packages()
), file = 'packages.bib')这里,.packages()函数可以直接把环境中使用的所有包的字符串作为向量返回。路径和文件名在file参数中进行设置。
有多条输出的时候,加上这么一段代码,方便导入到NoteExpress。
a = readLines("packages.bib")
a[a == "}"] = "}\n"
writeLines(a,"packages.bib")原文作者:;如有侵权,请联系管理员删除。