Citing R packages
I am having trouble citing R packages in the Nature formatting style. Whatever item type I use (I've tried Computer Program, Journal Article, Report, Book), they are not displayed as suggested in R. The URL and the version number are missing.
Which item type do you suggest, so that both URL and version number are cited?
According to R, the output should be like this: (I assume this is APA style)
Wickham, H. and Henry, L. (2018). tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions. R package version 0.8.1. https://CRAN.R-project.org/package=tidyr
So adapted for Nature, it should be:
Wickham, H. and Henry, L. tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions. R package version 0.8.1. https://CRAN.R-project.org/package=tidyr (2018)
Which item type do you suggest, so that both URL and version number are cited?
According to R, the output should be like this: (I assume this is APA style)
Wickham, H. and Henry, L. (2018). tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions. R package version 0.8.1. https://CRAN.R-project.org/package=tidyr
So adapted for Nature, it should be:
Wickham, H. and Henry, L. tidyr: Easily Tidy Data with 'spread()' and 'gather()' Functions. R package version 0.8.1. https://CRAN.R-project.org/package=tidyr (2018)
Thanks for your quick answers!
I checked another post from 2013 looking for a way to do this.
Before I stardted using Zotero, I wrote references manually and now that I do use it, I'm affraid of messing things up if I do that.
My idea right now is to split my Bibliography between R packages and scientific articles.
Would you advise I wait until the very end and unlink citations before mixing R packages with scientifc articles and having references strictly follow journal guidelines ?
I might need to move things again even if I think adding R package references will be the last thing I do, so I am reluctant to think about that option.
Thank you very much. I am currently using the Springer - Basic (author-date, no "et al.") style since I noticed that the current version I have of Wiley's "Plant pathology" style does not include "usual articles" DOIs (for me at least), and someone pointed out to me in another discussion I had mixed up the two. I just checked and it seems that Springer - Basic (author-date, no "et al.") does not yet (once again for me at least) include DOIs for links I get from CRAN.
Yes, here is what I have recieved from using "citation("lme4")" in R:
Douglas Bates, Martin Maechler, Ben Bolker, Steve Walker (2015). Fitting Linear Mixed-Effects Models Using lme4. Journal of Statistical Software, 67(1), 1-48. doi:10.18637/jss.v067.i01.
And here is what the Springer - Basic (author-date, no "et al.") style gives me after i click the "save to zotero" button from CRAN for lme4:
Bates D, Maechler M, Bolker [aut B, cre, Walker S, Christensen RHB, Singmann H, Dai B, Scheipl F, Grothendieck G, Green P, Fox J, Bauer A, simulate.formula) PNK (shared copyright on (2021) lme4: Linear Mixed-Effects Models using “Eigen” and S4.
The first argument should be a character vector of package names, and the second argument is the path to the .bib file. In the above example, .packages() returns the names of all packages loaded in the current R session. This makes sure all packages being used will have their citation entries written to the .bib file. When any of these packages are updated (e.g., the author, title, year, or version of a package is changed), write_bib() can automatically update the .bib file.
See https://bookdown.org/yihui/rmarkdown-cookbook/write-bib.html for more information
Most packages I want to cite are referenced as type "Manual," but that's not one of Zotero's item type options.
Zotero imported them as type "book," and the package version is imported in a nested note. That note won't be displayed in any formatting style.
So I tried by changing the type to "Software" and the "note" tag for a "version" tag in the .bib file, but that still doesn't provide the recommended citation.
Any other ideas on how to change the bib file to get the citation they recommend?
Maybe Zotero devs can create a "Manual" item type that supports note tags and show them in most citation styles?
Also, while .bib is widely used, it's at the same time quite limited and poorly standardized, so if at all possible I'd avoid taking a .bib file as a starting point. Why not start in Zotero?
I'm trying to add R package citations to Zotero in tandem (instead of one by one).
Every R package provides the information needed to be cited (in the DESCRIPTION file), and some R functions compile that information and create a .bib file.
That's why a .bib file is my starting point. Unfortunately, .bib is indeed very limited and poorly standardized, especially when created from the R packages description file.
I'm aware that correct citation depends on citation style and that I don't need to recreate the recommended citation. However, I agree with Hannah that URL and version are essential and should be reported in most citation styles.
So, my question is simply what the best item type for an R package citation would be to show both URL and version most of the time?
You can check the CITATION information in the package to see if the author would prefer a journal article be cited (in that case, I strongly suggest citing _both_ the package itself and the article), but I would rely on the metadata from CRAN for the package, as this will be more up to date and accurate
As of 2024, all R packages are assigned DOI. I simply visit the website for an R package such as https://cran.r-project.org/web/packages/icenReg/index.html, click the Zotero Connector as a Chrome extension to the right of the browser address box, and a new entry of the item type Software will be added to the current folder when Zotero is open. Then I click the newly added item in Zotero to open the Info section in the item pane,
- add "R package" in the Programming Language box (or add a line "genre: R package" in the Extra box),
- add "Computer software" in the System box (or add a line "medium: Computer software" in the Extra box),
- add "Comprehensive R Archive Network" in the Company box (or add a line "publisher: Comprehensive R Archive Network" in the Extra box), and
- add a line "doi: 10.32614/CRAN.package.icenReg" in the Extra box directly from the CRAN webpage which will replace the automatically extracted URL in a bibliography entry.
- If one must italicize or reverse italicize the name of the package, add labels around the package name according to https://www.zotero.org/support/kb/rich_text_bibliography.
Note that the URL is overwritten by DOI and "R package" and "Computer software" is specified in square bracket in the bibliography output.
When I refer to a tutorial, manual, or vignette associated with a package, I still use Software as the Item Type, go to the CRAN page to import the entry via Zotero Connector for convenience, and add the document as attachment or link to file manually. Then I
- repeat the procedures stated above less the doi part,
- change the title from the software name to the document title in the Title box,
- change the link to the one of the document in the URL box, and
- add lines "container-title: Software name" and "references: Reference manual" or "references: Vignette" in the Extra box. By using the references variable, document type will be added in parentheses after the URL.
For additional manipulation using "variable: value" format in the Extra box, see https://docs.citationstyles.org/en/stable/specification.html#appendix-iv-variables. Note that only the first value will be picked when multiple lines are created for the same variable. For example, if "Windows" is already in the System box, adding a line "medium: Computer software" in the Extra box will result in ...[R package; Windows]... and the information "Computer software" will be omitted. I tested switching the Item Type to Manuscript with CSL variables "container-title, publisher, version, genre, medium" added in the Extra box, but it misplaces the [R package; Computer software] part after the manual title instead of the software name. By contrast, Document seems to work very similarly to Software as the Item Type with manipulation in the Extra box, except the date will be specified as day instead of year in the bibliography output.
For packages that has descriptive documents published as journal articles, I add entries of both the software and the journal article. The journal article is usually mentioned in the package description or function details. It can be also discovered by searching author and package name in google scholar. Once the DOI or the article link by the original publisher is found, use Zotero Connector to add the entry from a browser. Entries for journal articles are usually quite standard. The only thing that may require adjustment is switching the letter case of title to sentence case, by a right click in the Title box. Example writing the encompasses all these types associated with an R package is:
The model is estimated with the R package icenReg (Version 2.0.16; Anderson-Bergman, 2024a). The package implements reliable algorithms for fitting semiparametric regression models with interval censored data (Anderson-Bergman, 2017). Left-censored outcome is represented by setting the lower limit to zero and the upper limit to the detection limit (Anderson-Bergman, 2024b). Because fitting semiparametric models is computationally intense, 100 bootstrap samples of the estimator were taken from four parallel cores (Anderson-Bergman, 2024c).
Anderson-Bergman, C. (2017). icenReg: Regression models for interval censored data in R. Journal of Statistical Software, 81, 1–23. https://doi.org/10.18637/jss.v081.i12
Anderson-Bergman, C. (2024a). icenReg: Regression models for interval censored data (Version 2.0.16) [R package; Computer software]. Comprehensive R Archive Network. https://doi.org/10.32614/CRAN.package.icenReg
Anderson-Bergman, C. (2024b). Package ‘icenReg.’ In icenReg: Regression models for interval censored data (Version 2.0.16) [R package; Computer software]. Comprehensive R Archive Network. https://cran.r-project.org/web/packages/icenReg/vignettes/icenReg.pdf (Reference manual)
Anderson-Bergman, C. (2024c). Using icenReg for interval censored data in R. In icenReg: Regression models for interval censored data (Version 2.0.9) [R package; Computer software]. Comprehensive R Archive Network. https://cran.r-project.org/web/packages/icenReg/vignettes/icenReg.pdf (Vignette)