bdanalytics bdanalytics - 3 months ago 18
R Question

R: Unable to install Rcpp package for R 3.3.1 on OSX El Capitan

Am trying to install the R Rcpp package on Mac OS X El Capitan with a homebrew installation of R in an R console

> install.packages("Rcpp")
Installing package into ‘/usr/local/lib/R/3.3/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r- project.org/src/contrib/Rcpp_0.12.5.tar.gz'
Content type 'application/x-gzip' length 2397088 bytes (2.3 MB)
==================================================
downloaded 2.3 MB

* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** libs
clang++ -I/usr/local/Cellar/r/3.3.1/R.framework/Resources/include - DNDEBUG -I/usr/local/include -I/usr/local/opt/ - I/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/../include - I/Library/Java/JavaVirtualMachines/jdk1.8.0_66.jdk/Contents/Home/jre/../i nclude/darwin -I/usr/local/opt/gettext/include -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/usr/local/include -fPIC -g -O2 -c Date.cpp -o Date.o
Date.cpp:31:10: fatal error: 'Rcpp.h' file not found
#include <Rcpp.h>
^
1 error generated.
make: *** [Date.o] Error 1
ERROR: compilation failed for package ‘Rcpp’
* removing ‘/usr/local/lib/R/3.3/site-library/Rcpp’

The downloaded source packages are in
‘/private/var/folders/g8/rqv40nhs3zqcntnz_9t9l60w0000gr/T/Rtmpq2VPG3/ downloaded_packages’
Warning message:
In install.packages("Rcpp") :
installation of package ‘Rcpp’ had non-zero exit status


Tried searching for
Rcpp.h
with:

$locate Rcpp.h
/usr/local/lib/R/3.2/site-library/Rcpp/include/Rcpp.h


I could symlink to the
R/3.2
directory, but that seems risky ?

Tried:

brew update; brew install Rcpp


Received:


Error: No available formula with the name "rcpp"
==> Searching for similarly named formulae... Error: No similarly named formulae found.
==> Searching taps... Error: No formulae found in taps.


Session information:

> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin15.5.0 (64-bit)
Running under: OS X 10.11.5 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] tools_3.3.1

Answer

First, uninstall any previous dependencies via:

brew uninstall r

Next, try to install R under the following brew statements:

# Grab xquartz
brew install cask
brew cask install xquartz

# Install R w/ GCC (compiled under)
brew tap homebrew/science
brew install gcc
brew install r

Then try:

install.packages("Rcpp")