Git Product home page Git Product logo

grateful's Introduction

grateful: Facilitate citation of R packages

The diffify page for the R package grateful R-CMD-check Codecov test coverage Project Status: Active - The project has reached a stable, usable state and is being actively developed.

The goal of grateful is to make it very easy to cite R and the R packages used in any analyses, so that package authors receive their deserved credit. By calling a single function, grateful will scan the project for R packages used and generate a BibTeX file containing all citations for those packages.

grateful can then generate a new document with citations in the desired output format (Word, PDF, HTML, Markdown). These references can be formatted for a specific journal, so that we can just paste them directly into our manuscript or report.

Alternatively, we can use grateful directly within an Rmarkdown or Quarto document. In this case, a paragraph containing in-text citations of all used R packages will (optionally) be inserted into the Rmarkdown/Quarto document, and these packages will be included in the reference list when rendering.

Installation

You can install {grateful} from CRAN:

install.packages("grateful")

Or from GitHub:

# install.packages("remotes")
remotes::install_github("Pakillo/grateful")

Usage

grateful can be used in one of two ways:

  1. to generate a ‘citation report’ listing each package and their citations

  2. to build citation keys to incorporate into an existing R Markdown or Quarto document.

Example

Imagine a project where we are using the packages: dplyr, ggplot2, vegan and lme4. We want to collect all the citations listed for these packages, as well as a citation for base R (and for RStudio, if applicable).

Generate a document with formatted citations

Calling cite_packages() will scan the project, find these packages, and generate a document with formatted citations.

library(grateful)
cite_packages(out.dir = ".")            # save report to working directory


This document can also be a Word document, PDF file, markdown file, or left as the source Rmarkdown file using out.format:

cite_packages(out.format = "docx", out.dir = ".")

We can specify the citation style for a particular journal using citation.style.

cite_packages(citation.style = "peerj", out.dir = ".")

In all cases a BibTeX (.bib) file with all package citations will be saved to disk.


Using grateful with Rmarkdown or Quarto

If you are building a document in RMarkdown or Quarto and want to cite R packages, grateful can automatically generate a BibTeX file and ensure these packages are cited in the appropriate format (see template Rmarkdown and Quarto documents).

First, include a reference to the BibTeX file in your YAML header.

bibliography: grateful-refs.bib

(Note: You can reference multiple BibTeX files, if needed)

bibliography: 
  - document_citations.bib
  - grateful-refs.bib

Then call cite_packages(output = "paragraph") within a code chunk (block or inline) to automatically include a paragraph mentioning all the used packages, and include their references in the bibliography list.

```{r}
cite_packages(output = "paragraph", out.dir = ".")
```

We used R version 4.2.3 [@base] and the following R packages: lme4 v. 1.1.32 [@lme4], tidyverse v. 2.0.0 [@tidyverse], vegan v. 2.6.4 [@vegan].

Alternatively, you can get a table with package name, version, and citations, using output = 'table':

```{r }
pkgs <- cite_packages(output = "table", out.dir = ".")
knitr::kable(pkgs)
```

If you want the references to appear in a particular format, you can specify the citation style in the YAML header:

bibliography: grateful-refs.bib
csl: peerj.csl

Alternatively, you can cite particular packages using the citation keys generated by grateful, as with any other BibTeX reference, or just include citations in the References section, using the function nocite_references(). See the package help and the RMarkdown cookbook for more details.

Frequently Asked Questions

Getting just a table with used packages and versions

Use scan_packages

scan_packages()
         pkg version
1     badger   0.2.3
2       base   4.4.0
3      knitr    1.47
4    pkgdown   2.0.9
5    remotes   2.5.0
6       renv   1.0.7
7  rmarkdown    2.27
8   testthat 3.2.1.1
9  tidyverse   2.0.0
10    visreg   2.7.0

Producing a BibTeX file with package references

If you just want to get all package references in a BibTeX file, you can call get_pkgs_info(). Besides printing a table with package info, it will also save a BibTeX file with references. By default, the file will be called grateful-refs.bib, but you can change that (see function help).

If you want to get the BibTeX references for a few specific packages:

get_pkgs_info(pkgs = c("remotes", "renv"), out.dir = getwd())
#>       pkg version citekeys
#> 1 remotes   2.5.0  remotes
#> 2    renv   1.0.7     renv

Using grateful with the tidyverse

If you use one or several packages from the tidyverse, you can choose to cite the ‘tidyverse’ rather than the individual packages:

cite_packages(cite.tidyverse = TRUE)

Including package dependencies

Most R packages also depend on other packages. To include those package dependencies in your citations, rather than just the packages you called directly, use dependencies = TRUE:

cite_packages(dependencies = TRUE)

What about external software dependencies?

Some R packages wrap core external software that should perhaps be cited too. For example, rjags is an R wrapper to the JAGS software written in C++. Ideally, R packages wrapping core external software will include them in their CITATION file. But otherwise, we can investigate external software requirements of our used packages, e.g. using remotes:

remotes::system_requirements(package = c("rjags"), os = "ubuntu-20.04")
#> [1] "apt-get install -y jags"

What software to cite?

Citing software is pretty much like citing papers. Authors have to decide what to cite in each case, which depends on research context.

As written in the Software Citation Principles paper (Smith et al. 2016):

The software citation principles do not define what software should be cited, but rather how software should be cited. What software should be cited is the decision of the author(s) of the research work in the context of community norms and practices, and in most research communities, these are currently in flux. In general, we believe that software should be cited on the same basis as any other research product such as a paper or book; that is, authors should cite the appropriate set of software products just as they cite the appropriate set of papers, perhaps following the FORCE11 Data Citation Working Group principles, which state, “In scholarly literature, whenever and wherever a claim relies upon data, the corresponding data should be cited”

And these are the guidelines from the Software Citation Checklist:

You should cite software that has a significant impact on the research outcome presented in your work, or on the way the research has been conducted. If the research you are presenting is not repeatable without a piece of software, then you should cite the software. Note that the license or copyright of the software has no bearing on whether you should cite it.

This might include:

Software (including scripts) you have written yourself to conduct the research presented. A software framework / platform upon which the software you wrote to conduct the research relies. Software packages, plugins, modules and libraries you used to conduct your research and that perform a critical role in your results. Software you have used to simulate or model phenomena/systems. Specialist software (which is not considered commonplace in your field) used to prepare, manage, analyse or visualise data. Software being evaluated or compared as part of the research presented Software that has produced analytic results or other output, especially if used through an interface.

In general, you do not need to cite:

Software packages or libraries that are not fundamental to your work and that are a normal part of the computational and scientific environment used. These dependencies do not need to be cited outright but should be documented as part of the computational workflow for complete reproducibility. Software that was used during the course of the research but had no impact on research results, e.g. word processing software, backup software.

Apart from citing the software most relevant to the particular research/analysis performed, I think it is good idea to record the entire computational environment elsewhere, e.g. using sessionInfo() or sessioninfo::session_info().

Removing unused packages

Before running grateful you might want to run funchir::stale_package_check or annotater to check for unused packages before citing them.

Error: there is no package called…

If getting an error like “Error in (function (pkg, lib.loc = NULL): there is no package called…”, that means that some of your scripts is loading a package that is no longer available in your computer, so {grateful} cannot grab its citation. To fix this, there are several options. First, you could omit that package (or those packages, if more than one) from {grateful} citations using cite_packages(omit = c("package1", "package2"). Alternatively, try checking if that package is still needed for your project and you want to cite it, otherwise remove or comment that line where the package is loaded. If you still use and want to cite that package, install it, and then run cite_packages again.

Citing ‘grateful’

citation("grateful")
To cite package 'grateful' in publications use:

  Rodriguez-Sanchez F, Jackson C (2023). _grateful: Facilitate citation
  of R packages_. <https://pakillo.github.io/grateful/>.

A BibTeX entry for LaTeX users is

  @Manual{,
    title = {grateful: Facilitate citation of R packages},
    author = {Francisco Rodriguez-Sanchez and Connor P. Jackson},
    year = {2023},
    url = {https://pakillo.github.io/grateful/},
  }

Limitations

Citation keys are not guaranteed to be preserved when regenerated, particularly when packages are updated. This instability is not an issue when citations are used programmatically, as in the example above. But if references are put into the text manually, they may need to be updated periodically.

grateful's People

Contributors

connorp avatar jmclawson avatar pakillo avatar sdhutchins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grateful's Issues

Add an option for an output path

Hi, I'm curious if you've considered adding a out.path parameter to the cite_packages() function.

I'd love to be able to do the following:

  1. Save to a particular path...like a docs folder
  2. Set the out.format to NULL in cases where I want the out.format to be the .Rmd file.

My idea is for the default out.path to be null and it'd save it in the top love of the project folder.

cite_packages(out.format = "md". out.path = "docs")

I'm more than willing to contribute this change as well as add some a pkgdown site if that's desired.

This package has saved me a TON of time @Pakillo

Release grateful 0.2.4

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::build_readme()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

include.RStudio = TRUE does not work with output = "table"

No RStudio in the output table after knitting:

---
title: "Untitled"
output: html_document
bibliography: grateful-refs.bib
---

```{r}
library(R.utils)
library(grateful)
cite_packages(output = "table", out.dir = ".", include.RStudio = TRUE)
```

Replacing the last line with cite_packages(output = "paragraph", out.dir = ".", include.RStudio = TRUE) leads to RStudio being cited.

Output .bib file

Great package! Heads-up (in case useful): I just ran the following lines to generate a .bib file. Worth having a function to do this in the pkg? I suspect so...

pkgs = c(
  "grateful",
  "sf",
  "osmdata",
  "dodgr",
  "stplanr",
  "dplyr",
  "piggyback",
  "tidygraph",
  "sfnetworks",
  "purrr",
  "devtools"
  )
to_install = !pkgs %in% installed.packages()
if(any(to_install)) {
  install.packages(pkgs[to_install])
}
devtools::install_github("Pakillo/grateful")
#> Skipping install of 'grateful' from a github remote, the SHA1 (5fc74648) has not changed since last install.
#>   Use `force = TRUE` to force installation
purrr::map_lgl(pkgs, require, character.only = TRUE)
#> Loading required package: grateful
#> Loading required package: sf
#> Linking to GEOS 3.7.0, GDAL 2.3.2, PROJ 5.2.0
#> Loading required package: osmdata
#> Data (c) OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright
#> Loading required package: dodgr
#> Loading required package: stplanr
#> Warning in fun(libname, pkgname): rgeos: versions of GEOS runtime 3.7.0-CAPI-1.11.0
#> and GEOS at installation 3.6.2-CAPI-1.10.2differ
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> Loading required package: piggyback
#> Loading required package: tidygraph
#> 
#> Attaching package: 'tidygraph'
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> Loading required package: sfnetworks
#> Loading required package: purrr
#> Loading required package: devtools
#>  [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

cites = grateful::get_citations(pkgs)
#> Warning in FUN(X[[i]], ...): no date field in DESCRIPTION file of package
#> 'dplyr'
#> Warning in FUN(X[[i]], ...): no date field in DESCRIPTION file of package
#> 'sfnetworks'
lapply(cites, write, file = "pkg.bib", append = TRUE)
#> $grateful
#> NULL
#> 
#> $sf
#> NULL
#> 
#> $osmdata
#> NULL
#> 
#> $dodgr
#> NULL
#> 
#> $stplanr
#> NULL
#> 
#> $dplyr
#> NULL
#> 
#> $piggyback
#> NULL
#> 
#> $tidygraph
#> NULL
#> 
#> $sfnetworks
#> NULL
#> 
#> $purrr
#> NULL
#> 
#> $devtools
#> NULL

Created on 2019-01-08 by the reprex package (v0.2.1)

restrictive R version dependency

Depending on R versions >=3.4.1 seems kind of restrictive.

grateful won't install on my installation of R 3.4.0, but if I modify DESCRIPTION and rebuild, it seems to run just fine. Is there any reason you want to restrict to a recent version, or just that you haven't tested old versions?

error scanForPackages

Error loading grateful

> library(grateful)
Error: package or namespace load failed for ‘grateful’:
 object ‘scanForPackages’ is not exported by 'namespace:checkpoint'
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6
Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] es_ES.UTF-8/es_ES.UTF-8/es_ES.UTF-8/C/es_ES.UTF-8/es_ES.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] compiler_4.0.5    cli_2.5.0         htmltools_0.5.1.1 tools_4.0.5      
 [5] yaml_2.2.1        rmarkdown_2.9     knitr_1.33        xfun_0.24        
 [9] digest_0.6.27     checkpoint_1.0.0  rlang_0.4.11      evaluate_0.14 ```
 

`softbib`

Hi,

I just saw a post about your package on social media. Very cool!

I am the author of softbib, which does essentially the same thing: https://github.com/vincentarelbundock/softbib

Looking at CRAN release dates, this looks like another case of simultaneous invention: I released on March 3rd 2023 and you on April 24th of the same year.

I think this is a really important feature set, and I believe in software citations (I recently published a paper about this in my discipline: https://doi.org/10.1017/S1049096523000239)

But I'm not sure we need TWO packages for this. My preferred outcome would be to join efforts somehow, to avoid duplicating efforts and splitting the community across different workflows.

What do you think? If you look at softbib, do you see a path forward, or are the projects on different paths?

CITATION.cff files

Hi, this is a follow-up of the conversation on mastodon @sdruskat https://scholar.social/@sdruskat/110264829977856739

Just for introducing you a bit the cffr package this is a quick demo that show:

  1. How to read a CITATION.cff file
  2. How to convert it to a bibentry (BibTex) entry
  3. How to append that to a Bibtex file created with grateful
# Read a CITATION.cff file
f <- system.file("examples/reprozip.cff", package = "cffr")
library(cffr)

# cffr has its own class cff
cff_s3_class <-cff_read(f)
class(cff_s3_class)
#> [1] "cff"

# You can parse it to bibentries

tobib <- cff_to_bibtex(cff_s3_class, what = "preferred")
class(tobib)
#> [1] "bibentry"

tobib
#> Anonymous (ed.) (2016). _ReproZip: Computational Reproducibility With
#> Ease_, series SIGMOD '16. doi:10.1145/2882903.2899401
#> <https://doi.org/10.1145/2882903.2899401>.

# Use with grateful
library(grateful)
citekeys <- get_citations(c("knitr", "renv"), out.dir = tempdir())

# Read to bibtex file created
fgrateful <- file.path(tempdir(), "grateful-refs.bib")

readLines(fgrateful)
#>  [1] "@Manual{knitr2023,"                                                              
#>  [2] "title = {{knitr}: A General-Purpose Package for Dynamic Report Generation in R},"
#>  [3] "  author = {Yihui Xie},"                                                         
#>  [4] "  year = {2023},"                                                                
#>  [5] "  note = {R package version 1.42},"                                              
#>  [6] "  url = {https://yihui.org/knitr/},"                                             
#>  [7] "}"                                                                               
#>  [8] ""                                                                                
#>  [9] "@Book{knitr2015,"                                                                
#> [10] "  title = {Dynamic Documents with {R} and knitr},"                               
#> [11] "  author = {Yihui Xie},"                                                         
#> [12] "  publisher = {Chapman and Hall/CRC},"                                           
#> [13] "  address = {Boca Raton, Florida},"                                              
#> [14] "  year = {2015},"                                                                
#> [15] "  edition = {2nd},"                                                              
#> [16] "  note = {ISBN 978-1498716963},"                                                 
#> [17] "  url = {https://yihui.org/knitr/},"                                             
#> [18] "}"                                                                               
#> [19] ""                                                                                
#> [20] "@InCollection{knitr2014,"                                                        
#> [21] "  booktitle = {Implementing Reproducible Computational Research},"               
#> [22] "  editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},"           
#> [23] "title = {{knitr}: A Comprehensive Tool for Reproducible Research in {R}},"       
#> [24] "  author = {Yihui Xie},"                                                         
#> [25] "  publisher = {Chapman and Hall/CRC},"                                           
#> [26] "  year = {2014},"                                                                
#> [27] "  note = {ISBN 978-1466561595},"                                                 
#> [28] "}"                                                                               
#> [29] "@Manual{renv,"                                                                   
#> [30] "title = {{renv}: Project Environments},"                                         
#> [31] "  author = {Kevin Ushey},"                                                       
#> [32] "  year = {2023},"                                                                
#> [33] "  note = {R package version 0.17.3},"                                            
#> [34] "  url = {https://rstudio.github.io/renv/},"                                      
#> [35] "}"

bibtex::read.bib(fgrateful)
#> Xie Y (2023). _knitr: A General-Purpose Package for Dynamic Report
#> Generation in R_. R package version 1.42, <https://yihui.org/knitr/>.
#> 
#> Xie Y (2015). _Dynamic Documents with R and knitr_, 2nd edition.
#> Chapman and Hall/CRC, Boca Raton, Florida. ISBN 978-1498716963,
#> <https://yihui.org/knitr/>.
#> 
#> Xie Y (2014). "knitr: A Comprehensive Tool for Reproducible Research in
#> R." In Stodden V, Leisch F, Peng RD (eds.), _Implementing Reproducible
#> Computational Research_. Chapman and Hall/CRC. ISBN 978-1466561595.
#> 
#> Ushey K (2023). _renv: Project Environments_. R package version 0.17.3,
#> <https://rstudio.github.io/renv/>.

# With cffr you can add references to that

cffr::write_bib(tobib, file = fgrateful, append = TRUE)
#> ℹ Creating a backup of '/tmp/RtmpuhBdXk/grateful-refs.bib' in '/tmp/RtmpuhBdXk/grateful-refs.bib.bk1'
#> ℹ Writing 1 BibTeX entry ...
#> ✔ Results written to '/tmp/RtmpuhBdXk/grateful-refs.bib'

# And now we have added a citation from a CITATION.cff file

readLines(fgrateful)
#>  [1] "@Manual{knitr2023,"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
#>  [2] "title = {{knitr}: A General-Purpose Package for Dynamic Report Generation in R},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#>  [3] "  author = {Yihui Xie},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
#>  [4] "  year = {2023},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#>  [5] "  note = {R package version 1.42},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
#>  [6] "  url = {https://yihui.org/knitr/},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#>  [7] "}"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#>  [8] ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#>  [9] "@Book{knitr2015,"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [10] "  title = {Dynamic Documents with {R} and knitr},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [11] "  author = {Yihui Xie},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
#> [12] "  publisher = {Chapman and Hall/CRC},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#> [13] "  address = {Boca Raton, Florida},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
#> [14] "  year = {2015},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [15] "  edition = {2nd},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
#> [16] "  note = {ISBN 978-1498716963},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
#> [17] "  url = {https://yihui.org/knitr/},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
#> [18] "}"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [19] ""                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [20] "@InCollection{knitr2014,"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
#> [21] "  booktitle = {Implementing Reproducible Computational Research},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [22] "  editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#> [23] "title = {{knitr}: A Comprehensive Tool for Reproducible Research in {R}},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
#> [24] "  author = {Yihui Xie},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
#> [25] "  publisher = {Chapman and Hall/CRC},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#> [26] "  year = {2014},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [27] "  note = {ISBN 978-1466561595},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
#> [28] "}"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [29] "@Manual{renv,"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
#> [30] "title = {{renv}: Project Environments},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
#> [31] "  author = {Kevin Ushey},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
#> [32] "  year = {2023},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [33] "  note = {R package version 0.17.3},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
#> [34] "  url = {https://rstudio.github.io/renv/},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
#> [35] "}"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             
#> [36] "@Proceedings{rampinfreire:2016,"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
#> [37] "  title = {ReproZip: Computational Reproducibility With Ease},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
#> [38] "  author = {Remi Rampin and Juliana Freire and Fernando Chirigati and Dennis Shasha},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
#> [39] "  year = {2016},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [40] "  month = {jun},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [41] "  address = {San Francisco, US},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
#> [42] "  series = {SIGMOD '16},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
#> [43] "  doi = {10.1145/2882903.2899401},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
#> [44] "  abstract = {We present ReproZip, the recommended packaging tool for the SIGMOD Reproducibility Review. ReproZip was designed to simplify the process of making an existing computational experiment reproducible across platforms, even when the experiment was put together without reproducibility in mind. The tool creates a self-contained package for an experiment by automatically tracking and identifying all its required dependencies. The researcher can share the package with others, who can then use ReproZip to unpack the experiment, reproduce the findings on their favorite operating system, as well as modify the original experiment for reuse in new research, all with little effort. The demo will consist of examples of non-trivial experiments, showing how these can be packed in a Linux machine and reproduced on different machines and operating systems. Demo visitors will also be able to pack and reproduce their own experiments.},"
#> [45] "  date = {2016-06-26},"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
#> [46] "}"
bibtex::read.bib(fgrateful)
#> Xie Y (2023). _knitr: A General-Purpose Package for Dynamic Report
#> Generation in R_. R package version 1.42, <https://yihui.org/knitr/>.
#> 
#> Xie Y (2015). _Dynamic Documents with R and knitr_, 2nd edition.
#> Chapman and Hall/CRC, Boca Raton, Florida. ISBN 978-1498716963,
#> <https://yihui.org/knitr/>.
#> 
#> Xie Y (2014). "knitr: A Comprehensive Tool for Reproducible Research in
#> R." In Stodden V, Leisch F, Peng RD (eds.), _Implementing Reproducible
#> Computational Research_. Chapman and Hall/CRC. ISBN 978-1466561595.
#> 
#> Ushey K (2023). _renv: Project Environments_. R package version 0.17.3,
#> <https://rstudio.github.io/renv/>.
#> 
#> Anonymous (ed.) (2016). _ReproZip: Computational Reproducibility With
#> Ease_, series SIGMOD '16. doi:10.1145/2882903.2899401
#> <https://doi.org/10.1145/2882903.2899401>.

Created on 2023-04-26 with reprex v2.0.2

Package not found error

If there is only 1 unrecognized package, the program does not give any list?
In this case, do I have to transform all lines of code where the unrecognized package appears for grateful to run normally?

Thank you for the clarification!

Release grateful 0.2.0

First release:

  • usethis::use_cran_comments()
  • Update (aspirational) install instructions in README
  • Proofread Title: and Description:
  • attachment::att_amend_desc()
  • Check that all exported functions have @return and @examples
  • Check that Authors@R: includes a copyright holder (role 'cph')
  • Check licensing of included files
  • Review https://github.com/DavisVaughan/extrachecks
  • spelling::spell_check_package() or devtools::spell_check()
  • devtools::run_examples()
  • devtools::test_coverage()
  • goodpractice::gp()
  • rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))

Prepare for release:

  • git pull
  • devtools::build_readme()
  • urlchecker::url_check()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • devtools::check_mac_release()
  • devtools::check_rhub() or rhub::check_for_cran()
  • update cran_comments
  • git push

Submit to CRAN:

  • devtools::release()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • git push
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • git push

Cite base R by default

It would be nice to add an option to cite R itself when using the argument pkgs. A simple workaround is to add "base" to pkgs but this maybe could be done automatically...?

Example:

cite_packages(pkgs = c("grateful", "knitr"), output = "paragraph", out.dir = ".")

vs.

cite_packages(pkgs = c("grateful", "knitr", "base"), output = "paragraph", out.dir = ".")

Read output options from YAML

Would be good to be able to read options like the output format, citation processor (pandoc-citeproc or BibTeX), and any CSL files that are set in the document's YAML header, rather than having to also pass them to grateful. In particular:

  • cite_packages(…, citation.style)
  • nocite_references(…, citation_processor)

textNA not working

I'm trying to override the "Missing" default on NA values.

When I put it in tm_text, it does not override.

tm_shape(CAR) + tm_polygons("Graduates") +
tm_text("Label_Name", just = "top", auto.placement = TRUE, textNA = "No Frontline", colorNA = "#CC0000", col = "#000000") +
tm_layout(main.title = "Frontline Graduates by Country\nCaribbean", main.title.position = "center", inner.margins = c(.1, .2, .1, .2))

If I add a tm_fill layer, I get a warning that

tm_shape(CAR) + tm_polygons("Graduates") + tm_fill(textNA = "Frontline not implemented") +
tm_text("Label_Name", just = "top", auto.placement = TRUE, textNA = "No Frontline", colorNA = "#CC0000", col = "#000000") +
tm_layout(main.title = "Frontline Graduates by Country\nCaribbean", main.title.position = "center", inner.margins = c(.1, .2, .1, .2))

One tm layer group has duplicated layer types, which are omitted.

Any help would be appreciated.

Thanks

Please do not test citations in other packages (at least not on CRAN)

Hi,

When I'm checking the reverse dependencies of knitr, I discovered that grateful had some tests that were too strict, e.g.,

expect_identical(citkeys, c("knitr2023", "knitr2015", "knitr2014", "tidyverse"))

expect_identical(get_citation_and_citekey("knitr"),
structure(c("@Manual{knitr2023,",
title = "title = {{knitr}: A General-Purpose Package for Dynamic Report Generation in R},",
author = " author = {Yihui Xie},",
year = " year = {2023},",
note = paste0(" note = {R package version ", utils::packageVersion("knitr"), "},"),
url = " url = {https://yihui.org/knitr/},",
"}",
"",
"@Book{knitr2015,",
title = " title = {Dynamic Documents with {R} and knitr},",
author = " author = {Yihui Xie},",
publisher = " publisher = {Chapman and Hall/CRC},",
address = " address = {Boca Raton, Florida},",
year = " year = {2015},",
edition = " edition = {2nd},",
note = " note = {ISBN 978-1498716963},",
url = " url = {https://yihui.org/knitr/},", "}",
"",
"@InCollection{knitr2014,",
booktitle = " booktitle = {Implementing Reproducible Computational Research},",
editor = " editor = {Victoria Stodden and Friedrich Leisch and Roger D. Peng},",
title = "title = {{knitr}: A Comprehensive Tool for Reproducible Research in {R}},",
author = " author = {Yihui Xie},",
publisher = " publisher = {Chapman and Hall/CRC},",
year = " year = {2014},",
note = " note = {ISBN 978-1466561595},",
"}"),
class = "Bibtex"))
})

These tests assume that the citations for knitr would never change, which is not true, e.g., next year knitr2023 will become knitr2024 and the test would be broken, or new books/papers about knitr could be written and there could be more citation entries in https://github.com/yihui/knitr/blob/master/inst/CITATION, etc.

I'll be grateful if these tests are either removed or skipped on CRAN, so that I can freely make changes in knitr's citations in future without breaking grateful's tests. Thank you!

some packages not generating citations

Here is a reproducible example, some packages such as survival or future are not generating citations. I'm not sure if the error is because they have multiple citations? I looked at get_citation_and_citekey and add_citekey both give outputs

---
title: "example"
bibliography:
  - grateful-refs.bib
format: pdf
---

```{r}
library('survival')
library('future')
```

```{r}
grateful:::get_citation_and_citekey('survival')
```

```{r}
grateful:::add_citekey('survival', citation(package = "survival"))
```

```{r}
grateful::cite_packages(output = "paragraph",
                        out.dir = here::here(),
                        omit = NULL,
                        include.RStudio = F,
                        passive.voice = T)
```

```{r}
sessionInfo()
```

example.pdf

Release grateful 0.2.9

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::build_readme()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push

Submit to CRAN:

  • usethis::use_version('patch')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)

Written paragraph is limited

In some circumstances, the included wording may not be ideal for the citation paragraph. (E.g., authorial “we” isn’t used in the humanities and some social sciences for a single-author paper.)

In the long term, a templating system could be helpful. For the short term, a passive-voice option could add a lot of flexibility.

Passive voice not used when generating report

passive.voice = TRUE works well when output = "paragraph", but not when output = "file" (i.e. when generating a report).
Of course, I realised this just after releasing the new version on CRAN...

Integration with pacman

Really like the grateful package! But I've noticed it doesn't pick up packages that have been loaded via the p_load function in pacman. In the future, would you consider adding an extension to include packages in citations that have been loaded through pacman? There is a p_citation function in pacman that might be of use here, else perhaps a way to search for packages loaded via both standard library calls and via p_load?

More info on pacman here: https://cran.r-project.org/web/packages/pacman/pacman.pdf

Thanks for your consideration and keep up the good work!

Allow use with Rmd files

Great idea, but it should work within markdown and bookdown files, eg.:

```{r}
library(grateful)
cite_packages()

dependency 'checkpoint' is not available Error

Hello,

I get this error when trying to install your package via devtools::install_github

ERROR: dependency 'checkpoint' is not available for package 'grateful'

I am also unable to download the zip and install that way as well, as R tells me that it is not a properly installed binary package.

Thanks for your assistance.

Fred

If don't have rlang pre-installed, won't install grateful

Not sure if it's just on my machine, but because I didn't have rlang installed, I got the error:

Error: Failed to install 'grateful' from GitHub:
(converted from warning) cannot remove prior installation of package ‘rlang

Installed rlang and then installation works.

Fail to install 'unknown package' from GitHub

Dear,
I fail to install this R package (in the last released of Rstudio with R4.1.1) whereas it's seems to be very helpful.
When I copy/paste the install command line remotes::install_github("Pakillo/grateful"), I have these errors in return :
Erreur : Failed to install 'unknown package' from GitHub: error:1400410B:SSL routines:CONNECT_CR_SRVR_HELLO:wrong version number

Someone could help me ?

quarto supported?

Hi @Pakillo.
I love this pkg, and I use it a lot. Thanks.

Recently I'm creating new projects with quarto documents, so I would like to continue using this amazing pkg. Are you planing to include an option to also scan .qmd documents?

Can the access date be included on the citation?

Hi Pakillo,
I just found grateful and it's is great!..
I would like to suggest you if you can include, after the doi address of the citation, a "date access" information.
In some journals when I have cited some R packages they ask to me to include the date when I have access to the package in square brackets.
something like:
R Core Team (2013). R: A language and environment for statistical
computing. R Foundation for Statistical Computing, Vienna, Austria.
URL http://www.R-project.org/. [Accessed on August 2017]

Simple cite_packages call results in error

Hello,

I am trying to use grateful for the first time and finding an error with what I assume is the simplest use case. So I'm not sure if I'm missing some obvious point in the documentation or if there is a more subtle issue here. I have an R script running in Rstudio like so just to test grateful:

setwd('~/SLiMulation')
library(grateful)
cite_packages(out.dir = getwd())
library(tidyverse)
ggplot()

and receive the following error when running the cite_packages line:
Error in dirname(root) : a character vector argument expected

I have tried specifying "." as the out.dir instead as well as exactly copying the above setwd "/SLiMulation" into the out.dir option. The directory definitely exists, and is given as the directory with getwd(), and I've tried just using the home directory "" in setwd, which also clearly exists too. Since the error specifies it's looking for a character vector I've also used class() to check that indeed getwd() is returning a character. I've also tried not specifying out.dir at all but receive the following error:

Error in cite_packages() :
Please specify where to save the citation report, e.g. out.dir = getwd()

I wondered if the issue happens when no packages are used, so I also have tried running the cite_packages command individually after already loading tidyverse and running ggplot, so there is definitely one active package to cite. I was running somewhat older versions of R and Rstudio before, when I first got the error, and updated both to 4.4.0 and 2024.04.2 respectively, and still receive the error.

Thank you for your time,
Nick

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.