Skip to content

Commit

Permalink
Merge branch 'master' into update/dependencies-renv
Browse files Browse the repository at this point in the history
  • Loading branch information
collinschwantes authored Jan 9, 2024
2 parents bf61279 + 33e188d commit 0d6567d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions dependencies.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,19 @@ project](http://ropenscilabs.github.io/r-docker-tutorial/)

- 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

For some reason mac computers with mac silicon (e.g. M2 chip) have issues with
c compilers. Use the following to ensure your mac knows which c compiler to use.
- 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
Expand All @@ -26,5 +35,13 @@ 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`.

0 comments on commit 0d6567d

Please sign in to comment.