Skip to content

Commit 703f651

Browse files
committed
differences for PR #44
1 parent b4714a1 commit 703f651

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

03-reproducible-dev-environment.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,15 @@ renv::install("my_package")
249249
Let's install the packages we need for this script. At this time, we need `jsonlite`, `lubridate` and `ggplot2`.
250250

251251
```r
252-
renv::install("jsonlite", "lubridate", "ggplot2"),
252+
renv::install("jsonlite", "lubridate", "ggplot2")
253253
```
254254

255-
I can also install packages in any of the usual ways, i.e., `install.packages()` or `pak::pkg_install("ggplot2")`, but you'll have to complete an additional step to update the `lock` file enumerating packages and dependencies. A call to `renv::snapshot()` should suffice.
255+
We can also install packages in any of the usual ways, i.e., `install.packages()` or `pak::pkg_install("ggplot2")` and `renv` will intercept and install it in the environment.
256+
Then we need to run the `snapshot()` function to update the `renv.lock` file with all the packages installed.
257+
258+
```r
259+
renv::snapshot()
260+
```
256261

257262
Now we can open the `renv.lock` file and see that it stores a lot of machine-readable information in plain text. However, you could also <kbd>COMMAND</kbd>+<kbd>F</kbd> (MacOS) or <kbd>CTRL</kbd>+<kbd>F</kbd> (Windows) to double check that the packages installed are now listed.
258263

@@ -266,19 +271,26 @@ Let's delete the packages we just installed and then restore them using the exis
266271
remove.packages(c("jsonlite", "lubridate", "ggplot2"))
267272
```
268273

274+
269275
If you attempt to load these packages now, your get an error
270276

271277
```r
272-
library("jsonlite)
278+
library("jsonlite")
273279
```
274280

281+
::::::::::::::: instructor
282+
283+
If the call to load `jsonlite` succeeds they might need to restart the R session because they loaded it previously and it is cached.
284+
285+
:::::::::::::::::::::::::::
286+
275287
```output
276288
Error in library(jsonlite) : there is no package called ‘jsonlite’
277289
```
278290

279291
To restore the packages from the `renv.lock`,
280292
```r
281-
renv::restore("renv.lock")
293+
renv::restore()
282294
```
283295

284296
If you attempt to load these packages now, it will work!
@@ -359,7 +371,7 @@ We are now setup to run our code from the newly created R project
359371
360372
```bash
361373
362-
(venv_spacewalks) $ **Rscript eva_data_analysis.R**
374+
(venv_spacewalks) $ Rscript eva_data_analysis.R
363375
364376
```
365377

md5sum.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"links.md" "cc698995bc527d7023554c264a40395f" "site/built/links.md" "2026-01-06"
88
"episodes/01-introduction.md" "aedd91aa9540277fa8117dac59175311" "site/built/01-introduction.md" "2026-01-06"
99
"episodes/02-better-start-version-control.md" "5cadf92e5452c81cc335065f3febe4be" "site/built/02-better-start-version-control.md" "2026-03-03"
10-
"episodes/03-reproducible-dev-environment.md" "40dac2ebc2f1455e4f28e398b83faed9" "site/built/03-reproducible-dev-environment.md" "2026-03-17"
10+
"episodes/03-reproducible-dev-environment.md" "f8582900accf8ab6bf99d1986395fa6f" "site/built/03-reproducible-dev-environment.md" "2026-03-24"
1111
"episodes/04-code-readability.md" "9ded137f2475f805c5bf250eb6a474c5" "site/built/04-code-readability.md" "2025-11-26"
1212
"episodes/05-code-structure.md" "df8f796a89810f2948c7955888d4733f" "site/built/05-code-structure.md" "2025-11-26"
1313
"episodes/06-code-correctness.md" "12a2163fc48ee5457e2e7518529643b9" "site/built/06-code-correctness.md" "2025-11-26"
@@ -23,4 +23,3 @@
2323
"learners/ethical-environmental-considerations.md" "a21d2780d9d1fc86bd1104a214edbd26" "site/built/ethical-environmental-considerations.md" "2025-09-30"
2424
"learners/setup.md" "a10c74c631874c01812d705a4286c1ad" "site/built/setup.md" "2026-03-23"
2525
"profiles/learner-profiles.md" "8fb91d65843f75b9b4aa60783eb65389" "site/built/learner-profiles.md" "2025-09-30"
26-
"renv/profiles/lesson-requirements/renv.lock" NA "site/built/renv.lock" "2026-03-24"

0 commit comments

Comments
 (0)