-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenv project setup.R
42 lines (31 loc) · 1.57 KB
/
renv project setup.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Script: renv project setup.R
## Using {renv} package setup environment for this project
library(renv)
# 1. Initialize environment for this specific project
# Call renv::init() to start using renv in the current project. This will
## Setup project infrastructure
## Discover packages and install them into a project library
## Create a lockfile that records the state of the project
renv::init()
# 2. Run all required scripts. Whilst building the Shiny app I will be installing
# specific libraries for different types of analysis and shiny app sections building
## Install one or more R packages on this isolated environment for this project.
# the local cache of pcakges installations is used when possible.
renv::install('pacman')
renv::install('here')
renv::install('tidyverse')
renv::install('janitor')
renv::install('shiny')
renv::install('DT')
renv::install('shinydashboard')
renv::install('zoo') # Install {zoo} package used in script "02_Metrics_population_rates.R
renv:: install('pacman') # Install {pacman} package used in script "03_Shiny_app_data_load.R
# 3 Check status of your lockfile using renv::status() function:
## status() reports issues caused by inconsistencies across the project lockfile
renv::status()
# 4 After we have confirmed the code works as expected, we use renv::snapshot()
## To record the packages and their sourecs in the lockfile
renv::snapshot()
# 5. To replicate this project in any machine, once all outputs have been created
# restore() > Restore a project's dependencies from a lockfile, as previously generated by snapshot()
# renv::restore()