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)
  • citation("tidyr") should give you a bibtex format, no?
  • We simply don't account for computer Programs in Nature style currently.Could probably be added
  • Yes, citation ("tidyr") gives me the bibtex format, that's how I created the above citation examples.I'll simply have to add it manually to the reference section for now.Adding it would be great!
  • But it's just a suggestion provided by R, not an obligation.
  • Alright, thank you!I like giving the authors credits for their packages, that's all.:)
  • Citing is mandatory, the format is only suggested
  • Ok, thank you for specifying.You're right, the format is not obligatory, but version number and URL are essential, and not currently included in the Nature style.Adding the references manually is a solution for now.

    Thanks for your quick answers!
  • right, but the version number would certainly be part of a citation for software in any style.
  • 188BET靠谱吗Hi, I am looking for the same thing, a possibility to add R-package references directly via Zotero.

    I checked another post from 2013 looking for a way to do this.

    188BET靠谱吗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.
  • 188BET靠谱吗You can add R packages to Zotero directly from CRAN.Some citation styles cite them properly.If you are using one that doesn't, let is know which and provide a sample citation from the guidelines or a recent paper

  • 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.
  • Could you given an example -- most R packages don't have DOIs unless there's a companion publication in JOSS or the like.

  • 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.

    188BET靠谱吗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 issue is that the citation() function asks you to cite the journal article published in JSS, not the R package directly from CRAN.You should add the JSS article citation by DOI and cite that.
  • edited July 1, 2021
    We aren't currently trying to get the citation info from CRAN for packages with associated publication, just parsing the metadata.If you want to cite the JSS article, just import the item via DOI in the add by identifier field.
  • @adamsmithYeah, the CITATION information in packages is honestly very inconsistent.It usually takes a fair amount of human judgment to decide what to do with it.The BibTeX especially isn't really reliably formatted since it's human-constructed typically.I think the basic strategy currently used it correct—I've been taking some notes on places where the metadata parsing could be improved that I'll open an issue for.
  • I don't know if this will be useful for you in 2021 but you can simple create a .bib file of all packages loaded using " knitr::write_bib(c(.packages(), "bookdown"), "packages.bib") ".188BET靠谱吗Then skim through to validate/update the entries before importing to Zotero ( by double clicking on the .bib you just created)

    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.htmlfor more information
  • Note that often those bib files will produce incorrect citations, especially for APA style.188BET靠谱吗So always double check how the data imports into Zotero and clean as necessary.
  • 188BET靠谱吗I also created a .bib file with the R package citations that I needed and imported them to Zotero.
    188BET靠谱吗Most packages I want to cite are referenced as type "Manual," but that's not one of Zotero's item type options.

    188BET靠谱吗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?

    188BET靠谱吗Maybe Zotero devs can create a "Manual" item type that supports note tags and show them in most citation styles?

  • I don't quite understand what you are trying to do, but generally speaking, there's no reason to try to recreate "recommended citations": correct software citations differ by citation style, just like correct citations for journal articles do.

    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.188BET靠谱吗Why not start in Zotero?
  • Thanks for the answer.
    188BET靠谱吗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?
  • 188BET靠谱吗Folks, to be clear, you should enter R packages in Zotero as "Software".188BET靠谱吗Generally, the best place to start with importing them to Zotero is the CRAN package page with the Zotero connector button in your browser toolbar, which will include version and URL.From there, you can make minor tweaks to the data (eg, to add "R package" to the Programming Language field so that is labeled in APA style).

    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
  • Thanks bwiernik!That's very clear.
  • edited 28 days ago
    I like bwiernik's method.Herein I present my strategy of generating accurate APA style citations of R packages, tutorials, manuals, vignettes, and articles188BET靠谱吗in Zotero based on a final output example given at https://tfse.mikewk.com/reference/apa_citation.htmland illustrations provided in Section 10.10 Computer Software, Mobile Apps, Apparatuses, and Equipment of American Psychological Association.(2020).Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000.Authors needing other styles will also benefit from the following procedures.The bibliography output in the APA style is given at the end.

    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.html188BET靠谱吗, 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.188BET靠谱吗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 188BET靠谱吗//www.brodersterzo.com/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 vignette188BET靠谱吗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.188BET靠谱吗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)

Sign Inor Registerto comment.