I'm currently running jupyter + R on my Mac but every time I try to load an Excel (XLS) file, things fail. After hours of troubleshooting, I think I've narrowed down the problem and solution.
Problem
If you're Mac looks like this, you might have a hard time installed XLConnect
.
Here's what my error commonly looked like.
The key error messages were:
1: In install.packages("XLConnect") :
installation of package ‘rJava’ had non-zero exit status
2: In install.packages("XLConnect") :
installation of package ‘XLConnectJars’ had non-zero exit status
3: In install.packages("XLConnect") :
installation of package ‘XLConnect’ had non-zero exit status
My Solution
I cannot promise you that this will work but it worked for me.
Step 0 - Install JDK using Homebrew
DO THIS FIRST!!!
Read this tutorial on how to install the Java Development Kit using Homebrew.
Step 1 - Double Check Your Work
Things are looking good if you see this while typing:
java -version
Then run this command.
sudo R CMD javareconf
Step 2 - Start R
After you've installed the Java JDK, start R
.
r
Step 3 - Install rJava
Package
R
uses CRAN
as its package manager but we're going to install a specific version of rJava
for macOS.
install.packages("https://cran.r-project.org/src/contrib/Archive/rJava/rJava_0.9-9.tar.gz")
Things are looking good if you see this.
Step 4 - Install XLConnect
Package
XLConnect
is the library required to start working with XLS files.
install.packages('XLConnect', repos='https://cran.cnr.berkeley.edu/')
Things are looking good if you see this.