Setting up a reproducible R environment on macOS

Using renv is an excellent choice for maintaining a clean and reproducible R environment on macOS. Here, I will share my experiences and provide a guide on setting up R on macOS. The post is divided into the following sections: Installing system dependencies required for R libraries using Homebrew. Installing R libraries using renv. Saving and restoring R environments using renv. Installing R libraries hosted on private repositories. Building R libraries from source using Makevars. Let’s get started! ...

October 10, 2022 · 5 min · Firas Sadiyah

Using reticulate in RStudio with pyenv

When developing in Python, it is generally a good practice not to rely on the Python version that ships with the operating system (OS). This is to ensure that the system version of Python remains relatively ‘clean’ for the OS processes. In addition, by installing a custom version(s) of Python, we open many possibilities. For one, it gives us control over which specific version(s) to use in our projects, and two, by using a virtual environment manager, we ensure that each project has access to its own tailored list of packages. One way of achieving this is by using pyenv. ...

April 28, 2021 · 4 min · Firas Sadiyah

Using data.table with OpenMP support

If you are facing difficulties with large data sets in R, using data.table could provide a performance boost. However, when loading data.table, especially on macOS, you might encounter a warning indicating the absence of OpenMP support, causing data.table to operate in a single-threaded mode. This limitation prevents you from fully utilizing the potential benefits of using data.table and taking advantage of the underlying hardware. 1library(data.table) 2data.table 1.14.0 using 1 threads (see ?getDTthreads). Latest news: r-datatable.com 3********** 4This installation of data.table has not detected OpenMP support. 5It should still work but in single-threaded mode. 6If this is a Mac, please ensure you are using R>=3.4.0 and have followed our Mac instructions here: 7https://github.com/Rdatatable/data.table/wiki/Installation. 8This warning message should not occur on Windows or Linux. If it does, please file a GitHub issue. 9********** 10 11getDTthreads() 12[1] 1 What is the issue here? OpenMP is an implementation of multithreading, and the Clang compiler that comes with Xcode on macOS lacks support for OpenMP. Apple has chosen not to include the libomp.dylib run-time library in their compiler. You can verify this by executing the following command. ...

April 26, 2021 · 4 min · Firas Sadiyah