Last active
November 28, 2024 22:55
-
-
Save sueszli/3e2b29b1b7b80471e1bcce6055f1c9ba to your computer and use it in GitHub Desktop.
gfortran for R packages on ARM based machines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this container just serves to install the `klaR` package | |
# | |
# usage: | |
# | |
# $ docker compose up -d | |
# $ docker compose exec main Rscript -e "rmarkdown::render('ex7.rmd', output_format = 'pdf_document')" | |
services: | |
main: | |
container_name: main | |
volumes: | |
- type: bind | |
source: . | |
target: /workspace | |
working_dir: /workspace | |
ports: | |
- '8888:8888' | |
build: | |
context: . | |
dockerfile_inline: | | |
FROM --platform=linux/amd64 ubuntu:20.04 | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt-get clean && rm -rf /var/lib/apt/lists/* && apt-get update | |
RUN apt-get install -y ca-certificates | |
RUN update-ca-certificates | |
# pandoc | |
RUN apt-get install -y --no-install-recommends pandoc texlive-latex-base texlive-fonts-recommended | |
RUN apt-get install -y --no-install-recommends texlive-latex-extra texlive-xetex texlive-lang-japanese | |
RUN apt-get install -y --no-install-recommends texlive-fonts-extra texlive-lang-cjk texlive-latex-recommended texlive-bibtex-extra | |
RUN apt-get install -y --no-install-recommends texlive-science texlive-pictures biber libfreetype6-dev libfontconfig1-dev | |
# fortran 9 | |
RUN apt-get install -y gfortran-9 | |
RUN update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-9 100 | |
# r | |
RUN apt-get clean | |
RUN apt-get autoremove | |
RUN apt-get update | |
RUN apt-get install -y --no-install-recommends r-base r-base-dev | |
RUN apt-get install -y automake build-essential zlib1g-dev r-cran-httpuv | |
RUN Rscript -e 'for(p in c("rmarkdown", "ISLR", "IRkernel")) install.packages(p, repos = "https://cran.rstudio.com")' | |
# klar package | |
RUN Rscript -e 'install.packages("klaR", repos = "https://cran.rstudio.com")' | |
CMD ["tail", "-f", "/dev/null"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In short: the
klaR
package requires you to have agfortran
compiler installed.This can be done either through the Dockerfile above or – if you're using an ARM based MacOS system, simply by installing
gcc
first.Verify the successful installation of this package with the following command: