|
299 | 299 | "\n",
|
300 | 300 | "#### 2. List dependencies\n",
|
301 | 301 | "\n",
|
302 |
| - "Dependencies can be listed as `Imports` (required packages) or `Suggests` (optional/development packages).\n", |
| 302 | + "Dependencies can be listed as:\n", |
| 303 | + "\n", |
| 304 | + "* `Imports` (required packages).\n", |
| 305 | + "* Suggests` (optional/development packages).\n", |
303 | 306 | "\n",
|
304 | 307 | "For non-package projects, it's simplest to list all dependencies under `Imports`, which will be identified by `renv` (whilst those under `Suggests` may not unless used in scripts).\n",
|
305 | 308 | "\n",
|
306 | 309 | "`Suggests` is more relevant when constructing a package, as it distinguishes packages necessary only for optional features, vignettes or testing, from those required within the package itself.\n",
|
307 | 310 | "\n",
|
308 | 311 | "**Note:** In the [R Packages](https://r-pkgs.org/description.html) book, they recommend that - in `DESCRIPTION` - no versions are specified, or a minimum version is specified if you know that an older version of specific package/s would break the code. This is why it is important to also create an `renv.lock` file (as below), so you do have a record of the exact versions used.\n",
|
309 | 312 | "\n",
|
| 313 | + "Example `DESCRIPTION` with packages `dplyr` and `future`:\n", |
| 314 | + "\n", |
| 315 | + "```\n", |
| 316 | + "Package: example\n", |
| 317 | + "Title: Example DESCRIPTION\n", |
| 318 | + "Version: 0.0.0.9000\n", |
| 319 | + "Authors@R: \n", |
| 320 | + " person(\"Amy\", \"Heather\", , \"[email protected]\", role = c(\"aut\", \"cre\"))\n", |
| 321 | + "Description: This is an example DESCRIPTION, used for environment management.\n", |
| 322 | + "License: MIT + file LICENSE\n", |
| 323 | + "Encoding: UTF-8\n", |
| 324 | + "Roxygen: list(markdown = TRUE)\n", |
| 325 | + "RoxygenNote: 7.0.0\n", |
| 326 | + "Imports:\n", |
| 327 | + " dplyr\n", |
| 328 | + " future\n", |
| 329 | + "```\n", |
| 330 | + "\n", |
310 | 331 | "#### 3. Install packages from `DESCRIPTION`\n",
|
311 | 332 | "\n",
|
312 | 333 | "Install packages listed in `DESCRIPTION` (and their dependencies) with:\n",
|
|
445 | 466 | "* Specify minimum or exact versions in your `DESCRIPTION` file.\n",
|
446 | 467 | "* Be aware that not all old versions are available for every R version; you may need to adjust your R version or accept a newer package.\n",
|
447 | 468 | "\n",
|
| 469 | + "To specify a minimum version in `DESCRIPTION`:\n", |
| 470 | + "\n", |
| 471 | + "```\n", |
| 472 | + "Imports:\n", |
| 473 | + " dplyr (>= 1.0.0)\n", |
| 474 | + "```\n", |
| 475 | + "\n", |
| 476 | + "To install a particular version using `renv` (which is then captured in `renv.lock` by calling `renv::snapshot()`):\n", |
| 477 | + "\n", |
| 478 | + "```\n", |
| 479 | + "renv::install(\"[email protected]\")\n", |
| 480 | + "```\n", |
| 481 | + "\n", |
448 | 482 | "#### Missing system dependencies\n",
|
449 | 483 | "\n",
|
450 | 484 | "Some R packages require external system libraries (e.g., C libraries, database clients) not installed by default.\n",
|
|
549 | 583 | "\n",
|
550 | 584 | "**Goal:** Clone a repository with a pre-configured `renv` environment, switch to the correct R version, restore dependencies, and run a basic R script.\n",
|
551 | 585 | "\n",
|
552 |
| - "Example repository: [amyheather/renv-reproduce-activity](https://github.com/amyheather/renv-reproduce-activity/)\n", |
| 586 | + "**Repository:** [amyheather/renv-reproduce-activity](https://github.com/amyheather/renv-reproduce-activity/)\n", |
553 | 587 | "\n",
|
554 | 588 | "```{dropdown} View solution\n",
|
555 | 589 | "\n",
|
556 |
| - "1. **Clone the example repository.**\n", |
| 590 | + "1. **Clone the provided repository.**\n", |
557 | 591 | " * `git clone https://github.com/amyheather/renv-reproduce-activity.git`\n",
|
558 | 592 | " * `cd renv-reproduce-activity`\n",
|
559 | 593 | "2. **Switch to the required R version.**\n",
|
|
0 commit comments