Last active
October 11, 2024 17:39
-
-
Save christianrickert/8c1634a7f749589ff915368f66869aa1 to your computer and use it in GitHub Desktop.
Install 'data.table' R package with OpenMP on MacOS
This file contains 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
## R expects this file to be in its hidden config folder | |
# mkdir ~/.R | |
# touch ~/.R/Makevars | |
## Install 'OpenMP' using Homebrew in Terminal | |
# brew update && brew install libomp | |
## Include 'OpenMP' library with clang | |
HOMEBREW_PATH=/opt/homebrew | |
# 'openmp' was symlinked (package) | |
CPPFLAGS += -I$(HOMEBREW_PATH)/include | |
LDFLAGS += -L$(HOMEBREW_PATH)/lib | |
# 'openmp' wasn't symlinked (keg-only) | |
CPPFLAGS += -I$(HOMEBREW_PATH)/opt/libomp/include | |
LDFLAGS += -L$(HOMEBREW_PATH)/opt/libomp/lib | |
## Enable 'OpenMP' library with clang | |
CPPFLAGS += -Xclang -fopenmp | |
LDFLAGS += -lomp | |
## Install these packages to avoid compilation errors | |
# brew install xquartz | |
# brew install tcl-tk | |
## Install 'data.table' with R console | |
# remove.packages("data.table") | |
# install.packages("data.table", type = "source") | |
## Load 'data.table' with R console and test | |
# library("data.table") | |
# test.data.table() |
Successfully tested with Sonoma 14.7 and R 4.4.1 "Race for your Life"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Successfully tested with Sonoma 14.6.1 and R 4.4.1 "Race for your Life".