forked from ecohealthalliance/eha-ma-handbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdependencies.Rmd
47 lines (30 loc) · 3.44 KB
/
dependencies.Rmd
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
42
43
44
45
46
47
# Dependency Management {#dependencies}
*How do I make sure that all my software and configurations needed for a projects are portable?*
- [renv](https://rstudio.github.io/renv/articles/renv.html) captures package versions and sources as well as R version. `renv` also records python versions and virtual environments for projects that used both languages.
- The [capsule](https://github.com/MilesMcBain/capsule) package can be useful when you want version control/depedency management but not the full weight of `renv`. Sometimes, `renv` can be an impediment for smaller and highly collaborative projects, that is where capsule can be useful. Ultimately, capsule will allow to setup `renv` for a project when it gets to a stable state.
- [Docker](https://www.docker.com/) allows you to create virtual machines, meaning you can capture all system dependencies in addition to the dependencies captured in `renv`. It works for essentially any programming language and is extremely flexible.
- [UseR 2022 Docker workshop](https://github.com/rsangole/user2022-r-for-docker/tree/main)
- [A lesson in user Docker for an R
project](http://ropenscilabs.github.io/r-docker-tutorial/)
- Makefiles can automate a complex, multipart project. Here's [a lesson on them from Software Carpentry](http://swcarpentry.github.io/make-novice/)
- R packages can be a useful project output. We have some in-house R packages to provide access to internal data and generate reports, and may be developing more for external audiences. Hadley Wickham's [R Packages Book](http://r-pkgs.had.co.nz/) provides guidance for these, and we expect our packages to be up to [rOpenSci standards](https://github.com/ropensci/onboarding).
## GCC and mac silicon
- R package installation can be especially tricky on Mac computers with [Apple Silicon](https://support.apple.com/en-us/HT211814). Below are some steps to get
package install set ups.
1. Install the R compilation tool chain https://mac.thecoatlessprofessor.com/macrtools/. If any issues with FORTRAN, follow instructions for downloading FORTRAN compiler here for Apple silicon Macs: <https://mac.r-project.org/tools/>
2. Install gcc `brew install gcc`. This requires having brew set up.
3. Make sure homebrew is in terminal path. Add it by `export PATH=$PATH:/opt/homebrew/bin`.
4. Create `~/.R/Makevars` and insert the following. This will need to be updated depending on gcc version.
```
CXX14FLAGS += -O3 -arch arm64 -ftemplate-depth-256
FC = /opt/homebrew/Cellar/gcc/13.2.0/bin/gfortran
F77 = /opt/homebrew/Cellar/gcc/13.2.0/bin/gfortran
FLIBS = -L/opt/homebrew/Cellar/gcc/13.2.0/lib/gcc/13
```
5. RStudio may have a bug in accessing the correct terminal path. The workaround is to copy your terminal path (`echo $PATH`) into `.Renviron` per instructions here: <https://community.rstudio.com/t/how-to-get-rstudio-ide-to-use-the-correct-terminal-path-in-mac-os-x/131528/6>
6. Some packages may need additional help for R to find the correct paths. For `units`:
`remotes::install_version(package = "units",
version = "0.8-5",
configure.args = "--with-udunits2-lib=/opt/homebrew/Cellar/udunits/2.2.28/lib --with-udunits2-include=/opt/homebrew/Cellar/udunits/2.2.28/include")`
##
Historically some projects used [Packrat](https://rstudio.github.io/packrat/) or [checkpoint](https://CRAN.R-project.org/package=checkpoint) to fix R package versions. These systems have been superceded by `renv`.