Tuesday, September 18, 2018

MacOS R Studio via AnaConda installing nloptr

If you installed AnaConda and used RStudio coming with it, You might have run into issues install.packages("car")
It would tell you Configuration errors trying to compile nloptr package telling you can't compile C++ code and ask you to try --host option.

Basically the failure is because car depends on nloptr package and newest nloptr package is only distribute as source (Mac binary is several years behind). Yet you can't compile C++ code from within R Studio (actually R) that was launched from Conda nevigator.

There is no solutions posted online although quite a few people ran into this issue.
The solution is to install nloptr using conda command (sudo)

Like:
conda install -c conda-forge r-nloptr 

You may need to sudo on MacOS (or Linux)

This command actually works on MacOS, Linux and windows.

No comments: