Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install missing packages in a local library #262

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,46 @@ The example here uses the 'admiralverse' -- a toy universe defined as every
package on CRAN today (2024-12-07), with a website, and a name starting with
'admiral'.

```{r admiralverse}
admiralverse <- c(
"admiral",
"admiraldev",
"admiralonco",
"admiralophtha",
"admiralpeds",
"admiralvaccine"
)
```

You need:

* the package {dverse} to <u>d</u>ocument your uni<u>verse</u>,
* each package in the toy 'admiralverse' to access the documentation metadata,
* {dplyr} to manipulate the output of {dverse}, and
* {DT} to create a searchable table.

```{r dependencies}
#| echo: false
#| message: false

# Ensure the packages used here are installed; else install them in a local
# library to avoid forcing new dependencies in the system of the blog
# administrators

local_library <- tempfile()
dir.create(local_library)
# https://adv-r.hadley.nz/functions.html#on-exit
on.exit(unlink(local_library), add = TRUE, after = FALSE)

.libPaths(c(.libPaths(), local_library))

if (!requireNamespace("pak", quietly = TRUE)) {
install.packages("pak", lib = local_library)
}
# The cache is smart. It won't re-install what's already available
pak::pak(c("dverse", admiralverse, "dplyr", "DT"), lib = local_library)
```
Comment on lines 48 to +75
Copy link
Collaborator Author

@maurolepore maurolepore Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I ensure that the packages I need are installed; else I install them in a local library to be polite -- I want to avoid forcing new dependencies in your system.

Let me know if you do prefer me to install them at a more general level, maybe in the Dockerfile?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We install them as part of a workflow - I have added them now and so can close this PR :) blog is live!


```{r packages}
library(dverse)
library(admiral)
Expand Down Expand Up @@ -74,14 +107,6 @@ dverse::document_universe() takes the names of the packages in the
package.

```{r docs}
admiralverse <- c(
"admiral",
"admiraldev",
"admiralonco",
"admiralophtha",
"admiralpeds",
"admiralvaccine"
)
# For example: https://pharmaverse.github.io/admiral/reference/queries.html
template <- "https://pharmaverse.github.io/{package}/reference/{topic}.html"

Expand Down Expand Up @@ -195,3 +220,5 @@ insert_appendix(
file_name = list.files() %>% stringr::str_subset(".qmd") %>% first()
)
```


Loading