-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently, we obtain the list of R package dependencies in three instances:
Add Code
Lines 157 to 180 in 1e6b034
| R packages that you use in your analysis are an obvious example of dependencies. | |
| Their version is recorded by `renv`, | |
| but you also need to ensure that they are available for download. | |
| First, identify the source from which you installed your packages: | |
| ```{.r filename="Console"} | |
| # First, install {pak} and {sessioninfo} | |
| renv::install(c( | |
| "pak", | |
| "sessioninfo" | |
| )) | |
| # Which R packages does the project directly depend on? | |
| deps <- renv::dependencies()$Package |> | |
| unique() | |
| # Which R packages does the project indirectly depend on? | |
| deps <- deps |> | |
| pak::pkg_deps(dependencies = NA) |> | |
| getElement("package") | |
| # Get information about their source | |
| sessioninfo::package_info(deps) | |
| ``` |
Choose a License
code-publishing/choose_license.qmd
Lines 260 to 271 in 1e6b034
| 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 filename="Console"} | |
| deps <- renv::dependencies()$Package |> | |
| unique() |> | |
| pak::pkg_deps(dependencies = NA) |> | |
| getElement("package") | |
| unique(installed.packages(fields="License")[deps, "License"]) | |
| ``` |
Make a README
code-publishing/make_readme.qmd
Lines 86 to 100 in d7837ef
| An overview over the system dependencies of R packages can be created | |
| using the function `pak::pkg_sysreqs()`. | |
| In combination with `renv`, we can obtain the system dependencies | |
| of all R packages the current project directly depends on: | |
| ```{.r filename="Console"} | |
| # Find all R package dependencies | |
| deps <- renv::dependencies()$Package |> | |
| unique() |> | |
| pak::pkg_deps(dependencies = NA) |> | |
| getElement("package") | |
| # Identify their system dependencies | |
| pak::pkg_sysreqs(deps) | |
| ``` |
In all three instances, we query the top-level dependencies via renv::dependencies()$Package and then gather the recursive dependencies via pak::pkg_deps(). However, there's a shortcut to the answer because we are using renv: Just look at the lockfile via names(renv::lockfile_read()$Packages).
I should ponder about the pros and cons of directly querying the lockfile.
Metadata
Metadata
Assignees
Labels
No labels