Skip to content

Commit

Permalink
Moved reproducible environments to week 5
Browse files Browse the repository at this point in the history
  • Loading branch information
robjhyndman committed Mar 20, 2024
1 parent ad07079 commit 2f88684
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
1 change: 0 additions & 1 deletion week4/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ schedule |>
* Measuring performance
* Efficient R programming
* Caching
* Reproducible environments

## Online resources

Expand Down
31 changes: 0 additions & 31 deletions week4/slides.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -461,34 +461,3 @@ memo_sq(2)
## Exercises

4. Use `bench::mark()` to compare the speed of `sq()` and `memo_sq()`.

# Reproducible environments

## renv package

![](../diagrams/renv.png)

## renv package

* `renv.init()` : initialize a new project with a new environment. Adds:
* `renv/library` contains all packages used in project
* `renv.lock` contains metadata about packages used in project
* `.Rprofile` run every time R starts.

* `renv.snapshot()` : save the state of the project to `renv.lock`.

* `renv::restore()` : restore the project to the state saved in `renv.lock`.

## renv package
\fontsize{14}{16}\sf

* renv uses a package cache so you are not repeatedly installing the same packages in multiple projects.
* `renv::install()` can install from CRAN, Bioconductor, GitHub, Gitlab, Bitbucket, etc.
* `renv::update()` gets latest versions of all dependencies from wherever they were installed from.
* Only R packages are supported, not system dependencies, and not R itself.
* renv is not a replacement for Docker or Singularity.
* `renv::deactivate(clean = TRUE)` will remove the renv environment.

## Exercises

5. Add renv to your Assignment 1 project. Make sure the packages included are the latest CRAN versions of all packages.
3 changes: 2 additions & 1 deletion week5/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ schedule |>

## What you will learn this week

R Functional (functions, function arguments, function factories)
* Reproducible environments
* Functional programming (functions, function arguments, function factories)


```{r}
Expand Down
61 changes: 61 additions & 0 deletions week5/slides.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: ETC4500/ETC5450 Advanced R programming
author: "Week 4: Debugging and performance"
format:
beamer:
pdf-engine: pdflatex
aspectratio: 169
fontsize: "14pt,t"
section-titles: false
knitr:
opts_chunk:
dev: "cairo_pdf"
fig-width: 7.5
fig-height: 3.5
include-in-header: ../header.tex
keep-tex: true
---

```{r}
#| label: setup
#| include: false
#| cache: false
source(here::here("setup.R"))
source(here::here("course_info.R"))
```

## Outline

\vspace*{0.4cm}
\tableofcontents

# Reproducible environments

## renv package

![](../diagrams/renv.png)

## renv package

* `renv.init()` : initialize a new project with a new environment. Adds:
* `renv/library` contains all packages used in project
* `renv.lock` contains metadata about packages used in project
* `.Rprofile` run every time R starts.

* `renv.snapshot()` : save the state of the project to `renv.lock`.

* `renv::restore()` : restore the project to the state saved in `renv.lock`.

## renv package
\fontsize{14}{16}\sf

* renv uses a package cache so you are not repeatedly installing the same packages in multiple projects.
* `renv::install()` can install from CRAN, Bioconductor, GitHub, Gitlab, Bitbucket, etc.
* `renv::update()` gets latest versions of all dependencies from wherever they were installed from.
* Only R packages are supported, not system dependencies, and not R itself.
* renv is not a replacement for Docker or Singularity.
* `renv::deactivate(clean = TRUE)` will remove the renv environment.

## Exercises

5. Add renv to your Assignment 1 project. Make sure the packages included are the latest CRAN versions of all packages.

0 comments on commit 2f88684

Please sign in to comment.