Installing "rgl" package in R, Mac OSX El Captian
Asked Answered
W

4

12

I'm new to programming in R so I apologise in advance if I seem naive. I want to be able to do some principal components analysis on my data in 3D. I read that the "pca3d" function is good for this, but I need to download the "rgl" library. When I use install.packages it asks:

install.packages("rgl")

  There is a binary version available but the source version is later:
   binary    source needs_compilation
rgl 0.95.1201 0.95.1367              TRUE

Do you want to install from sources the package which needs compilation?
y/n: n

I have tried installing it as both binary and source, but nothing seems to work. If I try loading the binary version, I get this error:

Error : .onLoad failed in loadNamespace() for 'rgl', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl/libs/rgl.so
  Reason: image not found
Error: package or namespace load failed for ‘rgl’

If I say "yes" to installing from source, I get the following error:

configure: error: X11 not found but required, configure aborted.
ERROR: configuration failed for package ‘rgl’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/rgl’
Warning in install.packages :
 installation of package ‘rgl’ had non-zero exit status

I've been searching for hours on how to make this work so if someone could run through how I should go about installing the rgl package then I would be extremely grateful!

Thanks, Claire

Why answered 10/11, 2015 at 16:30 Comment(2)
As a start, the error message is saying that it looked for but could not find X11, so probably the first step is to install X11.Farra
you can try to add as non-default parametr repos into install.packages function, so it will be like that: install.packages("rgl", repos='http ://cran.cnr.berkeley.edu/') p.s. sorry, but delete a space between http and : symbolPelayo
W
17

After talking with a colleague all I had to do was download XQuartz from here to install X11, and then install the source package again. Now it works!

Why answered 11/11, 2015 at 10:0 Comment(0)
B
4

Downloading XQuartz completely solved everything after I wasted hours trying to come up with a solution to this problem.

Battat answered 10/2, 2016 at 23:51 Comment(0)
P
1

I first downloaded the package onto my desktop, but R gave me the same error, this is what worked for my Mac:

install.packages("rgl", lib="Desktop/rgl_0.96.0 (1).tgz") Warning in install.packages : 'lib = "Desktop/rgl_0.96.0 (1).tgz"' is not writable Would you like to use a personal library instead? (y/n) y Would you like to create a personal library ~/Library/R/3.3/library to install packages into? (y/n) y

Poppy answered 27/11, 2016 at 7:39 Comment(0)
P
1

In my case, not only install XQuartz but I need to also open XQuartz.app manually and then run install.packages("rgl").

Only by this way would R found X11 in my case...

Parchment answered 20/6, 2018 at 23:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.