Skip to content

Commit

Permalink
Use pak to calculate the dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fkohrt committed Sep 9, 2024
1 parent 0fa056d commit 9916def
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
15 changes: 5 additions & 10 deletions choose_license.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,11 @@ If a Quarto document contains both R code and writing, one may wonder what type
It is disputed whether software that uses an R package under AGPLv3 or GPLv3^[a variant of the AGPLv3 that does not cover software running as a service] can only be published under a GPL-compatible license -- or even has to be published under the same license. Posit, the company behind RStudio, does not believe that to be the case [see also @Wickham2023PackagesLicense]. You can learn which license an installed package uses via `packageDescription("<PACKAGE_NAME>", fields = "License")`. And to identify which licenses are being used by the R packages your project depends on, you can use the following code:

```r
direct_deps <- unique(renv::dependencies()$Package)
all_deps <- tools::package_dependencies(
packages = direct_deps,
which = "strong",
recursive = TRUE
) |>
unlist() |>
append(direct_deps) |>
unique()
unique(installed.packages(fields = "License")[all_deps, "License"])
deps <- renv::dependencies()$Package |>
unique() |>
pak::pkg_deps(dependencies = NA) |>
getElement("package")
unique(installed.packages(fields="License")[deps, "License"])
```
:::

Expand Down
2 changes: 1 addition & 1 deletion setup.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Although we provide the code in this example for you, a few things remain to be

- __Don't reinvent the wheel.__ With R, chances are that what you need to do is greatly facilitated by a package from one of many high-quality collections such as [rOpenSci](https://ropensci.org/packages/), [r-lib](https://github.com/r-lib), [Tidyverse](https://www.tidyverse.org/packages/), or [fastverse](https://fastverse.github.io/fastverse/).

- __Think twice about your dependencies.__ Every dependency increases the risk of irreproducibility in the future. Prefer packages that are well-maintained and light on dependencies^[You can use the [R package dependency badges](https://tinyverse.netlify.app/) to count the direct and total dependencies.]. We also recommend you to read "When should you take a dependency?" by @Wickham2023PackagesDependency.
- __Think twice about your dependencies.__ Every dependency increases the risk of irreproducibility in the future. Prefer packages that are well-maintained and light on dependencies^[You can use the function `pak::pkg_deps()` to count the total number of package dependencies in R.]. We also recommend you to read "When should you take a dependency?" by @Wickham2023PackagesDependency.

- __Fail early, often and noisily.__ Whenever you expect a certain state, use assertions to be sure. In R, you can use `stopifnot()` to make sure that a condition is actually true.

Expand Down

0 comments on commit 9916def

Please sign in to comment.