在分析数据时,我们需要引用R语言的特定版本,以及使用R包的版本,其实R语言中有代码可以调用,下面介绍一下。

1,引用R语言

在R语言中键入:

citation()

结果:

> citation()To cite R in publications use:R Core Team (2022). R: A language and environment for statisticalcomputing. 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 = {2022},url = {https://www.R-project.org/},}We have invested a lot of time and effort in creating R, please cite itwhen using it for data analysis. See also ‘citation("pkgname")’ forciting R packages.

里面有两种格式:

直接引用到出版物上:

R Core Team (2022). R: A language and environment for statisticalcomputing. R Foundation for Statistical Computing, Vienna, Austria.URL https://www.R-project.org/.

如果是BibText的LaTex格式,可以用这种格式:

@Manual{,title = {R: A Language and Environment for Statistical Computing},author = {{R Core Team}},organization = {R Foundation for Statistical Computing},address = {Vienna, Austria},year = {2022},url = {https://www.R-project.org/},}

各取所需。

2,引用R包

首先这个包是已经安装过的,比如ggplot2,可以写为:

citation("ggplot2")

注意:需要放到双引号里面,否则会报错。

代码运行结果:

> citation("ggplot2")To cite ggplot2 in publications, please use:H. Wickham. ggplot2: Elegant Graphics for Data Analysis.Springer-Verlag New York, 2016.A BibTeX entry for LaTeX users is@Book{,author = {Hadley Wickham},title = {ggplot2: Elegant Graphics for Data Analysis},publisher = {Springer-Verlag New York},year = {2016},isbn = {978-3-319-24277-4},url = {https://ggplot2.tidyverse.org},}> 

结果也是两种形式,一个是直接贴到文章中,一个是LaTex格式。

 H. Wickham. ggplot2: Elegant Graphics for Data Analysis.Springer-Verlag New York, 2016.

3,更灵活的方法

使用R包:pacman,里面的函数比较灵活,有:

  • p_cite
  • p_citation

它的优点R包不用双引号包裹,更灵活。

R包引用:

pacman::p_cite()
> pacman::p_cite()sh: xclip: command not foundTo cite R in publications use:R Core Team (2022). R: A language and environment for statisticalcomputing. 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 = {2022},url = {https://www.R-project.org/},}We have invested a lot of time and effort in creating R, please cite itwhen using it for data analysis. See also ‘citation("pkgname")’ forciting R packages.

也可以:

 pacman::p_citation()
> pacman::p_citation()sh: xclip: command not foundTo cite R in publications use:R Core Team (2022). R: A language and environment for statisticalcomputing. 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 = {2022},url = {https://www.R-project.org/},}We have invested a lot of time and effort in creating R, please cite itwhen using it for data analysis. See also ‘citation("pkgname")’ forciting R packages.

引用R包:

 pacman::p_cite(ggplot2)
> pacman::p_cite(ggplot2)sh: xclip: command not foundTo cite ggplot2 in publications, please use:H. Wickham. ggplot2: Elegant Graphics for Data Analysis.Springer-Verlag New York, 2016.A BibTeX entry for LaTeX users is@Book{,author = {Hadley Wickham},title = {ggplot2: Elegant Graphics for Data Analysis},publisher = {Springer-Verlag New York},year = {2016},isbn = {978-3-319-24277-4},url = {https://ggplot2.tidyverse.org},}

这样就不用担心引用R语言和R包了。