2

In Mendeley, the closest category for an R package appears to be "Computer Program"; however, R itself is a computer program, not its packages.

Other literature sources seem to cite technical documents about R packages instead of the actual packages.

Aside from manually entering the citations, is there a way to incorporate R packages in my Mendeley library?

3

6 Answers 6

7

Each R package has a different way to be cited. Some were formally published as scientific articles in journals, some only as packages. The only way to know for sure is to check how the package maintainer want you to cite their package, with function citation. Base R also comes with function toBibtex that help you export the correct citations as a bibtex file.

For instance:

> citation("Rcpp")

To cite Rcpp in publications use:

  Dirk Eddelbuettel and Romain Francois (2011). Rcpp: Seamless
  R and C++ Integration. Journal of Statistical Software,
  40(8), 1-18. URL http://www.jstatsoft.org/v40/i08/.

  Eddelbuettel, Dirk (2013) Seamless R and C++ Integration with
  Rcpp. Springer, New York. ISBN 978-1-4614-6867-7.

  Dirk Eddelbuettel and James Joseph Balamuta (2017). Extending
  R with C++: A Brief Introduction to Rcpp. PeerJ Preprints
  5:e3188v1. URL
  https://doi.org/10.7287/peerj.preprints.3188v1.

To see these entries in BibTeX format, use 'print(<citation>,
bibtex=TRUE)', 'toBibtex(.)', or set
'options(citation.bibtex.max=999)'.

> toBibtex(citation("knitr"))
@Manual{,
  title = {knitr: A General-Purpose Package for Dynamic Report Generation in R},
  author = {Yihui Xie},
  year = {2018},
  note = {R package version 1.20},
  url = {https://yihui.name/knitr/},
}

@Book{,
  title = {Dynamic Documents with {R} and knitr},
  author = {Yihui Xie},
  publisher = {Chapman and Hall/CRC},
  address = {Boca Raton, Florida},
  year = {2015},
  edition = {2nd},
  note = {ISBN 978-1498716963},
  url = {https://yihui.name/knitr/},
}

@InCollection{,
  booktitle = {Implementing Reproducible Computational Research},
  editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},
  title = {knitr: A Comprehensive Tool for Reproducible Research in {R}},
  author = {Yihui Xie},
  publisher = {Chapman and Hall/CRC},
  year = {2014},
  note = {ISBN 978-1466561595},
  url = {http://www.crcpress.com/product/isbn/9781466561595},
}

As for importing bibtex files into Mendeley, I do not use Mendeley myself but this Q&A on TeX.se shows that one can simply use menu items "File > Import... > Bibtex (*.bib) " to do so.

2
  • This is only a first step, to answer the question it would be helpful to explain how you get the output of the function into mendeley.
    – Leo
    Commented May 11, 2018 at 9:39
  • 1
    Yet another source for Bibtex entries which fails to escape titles correctly. :( Commented May 11, 2018 at 13:06
1

You could export the citation as a bibtex file, e.g. https://www.rforge.net/doc/packages/knitr/write_bib.html

1

With the bibtex package, you can generate a Bibtex file from the package citations and then upload it in Mendeley or another reference manager software. As an example

library(bibtex)
write.bib('package name - here', file='name for the file')
write.bib(c('bibtex', 'utils', 'tools'), file='references') ## for multiple packages

Please see the package's cran page (https://cran.r-project.org/web/packages/bibtex/) for further information

0

To add to the accepted answer, I believe you are looking for:

writeLines(toBibtex(citation("package")), con = 'path_to/reference_filename')

You can omit the package name for citing R.
Hope it saves someone a few minutes.

0
knitr::write_bib(c(.packages()), "packages.bib")

This will generate a .bib file containing all used packages, which you can add to Mendeley.

https://bookdown.org/yihui/rmarkdown-cookbook/write-bib.html

-2

For example, if I want to cite Data in Function reference http://ggplot2.tidyverse.org/reference/#section-data, in this case, I will use web page to added to Mendeley manually as follow:

1
  • I think that this is the wrong answer. Commented Mar 14, 2018 at 12:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .