[R] Failing to install the rgl package

David Winsemius dw|n@em|u@ @end|ng |rom comc@@t@net
Thu Jan 26 20:17:26 CET 2023


On 1/26/23 11:04, Tunga Kantarcı wrote:
> Hi,
>
> I try to execute the seven lines of code below to plot a graph. But I
> am failing as the messages below show. Where am I going wrong?
>
>
> install.packages("rgl")
> library(rgl)
> y_hat = X%*%B_hat
> open3d(windowRect = c(100,100,900,900),family = "serif")
> color = rainbow(length(y_hat))[rank(y_hat)]
> plot3d(educ,exper,wage,col = color,type = "s",size = 0.5,xlim =
> c(0,20),ylim = c(0,60),zlim = c(-10,70),box = FALSE,axes = TRUE)
> planes3d(B_hat[2],B_hat[3],-1,B_hat[1],alpha = 0.5,col = "azure")
>
>
>   -------------------------------------------------------------------------
>> install.packages("rgl")
> trying URL 'https://cran.rstudio.com/bin/macosx/contrib/4.1/rgl_1.0.1.tgz'
> Content type 'application/x-gzip' length 9425401 bytes (9.0 MB)
> ==================================================
> downloaded 9.0 MB
>
> The downloaded binary packages are in
> /var/folders/fx/_msf5ycn14g59c3vlc4pc7b80000gn/T//RtmpfaezHX/downloaded_packages
>> library(rgl)
> Registered S3 methods overwritten by 'rgl':
>    method               from
>    knit_print.rglId
>    knit_print.rglOpen3d
>    sew.rglRecordedplot
> Error in dyn.load(dynlib <- getDynlib(dir)) :
>    unable to load shared object
> '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgl/libs/rgl.so':
>    dlopen(/Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgl/libs/rgl.so,
> 0x0006): Library not loaded: /opt/X11/lib/libGLU.1.dylib
>    Referenced from: <82C7D9AE-E1B2-39EA-A909-163B033CF7B1>


So It appears that X11, a.k.a. XQuartz on a Mac, is failing to load. You 
probably need to reinstall XQuartz with a current version that matches 
your version of R. You are also getting a message saying Java sdk cannot 
be found.


You also appear to be attempting to load the version for R 4.1 while the 
current version of R is 4.2. The R "ecosystem" needs consistency in 
versions of R, XQuartz, Java, and R packages. You will probably get 
better success if you first upgrade R, then reinstall XQuartz,  then 
reinstall or update Java, and finally update all your installed packages 
including rgl and then give it another go.

Finally, this is Rhelp. There is a SIG for R-Mac users. This question 
would have been more on-topic for  that help mailing list.

-- 

David

> /Library/Frameworks/R.framework/Versions/4.1/Resources/library/rgl/libs/rgl.so
>    Reason: tried: '/opt/X11/lib/libGLU.1.dylib' (no such file),
> '/System/Volumes/Preboot/Cryptexes/OS/opt/X11/lib/libGLU.1.dylib' (no
> such file), '/opt/X11/lib/libGLU.1.dylib' (no such file),
> '/Library/Frameworks/R.framework/Resources/lib/libGLU.1.dylib' (no
> such file), '/Users/tunga/lib/libGLU.1.dylib' (no such file),
> '/usr/local/lib/libGLU.1.dylib' (no such file),
> '/usr/lib/libGLU.1.dylib' (no such file, not in dyld cache),
> '/lib/libGLU.1.dylib' (no such file),
> '/Library/Java/JavaVirtualMachines/jdk1.8.0_241.jdk/Contents/Home/jre/lib/server/libGLU.1.dylib'
> (no such file), '/var/folders/fx/_msf5ycn
> In addition: Warning message:
> package ‘rgl’ was built under R version 4.1.2
> Error: package or namespace load failed for ‘rgl’:
>   .onLoad failed in loadNamespace() for 'rgl', details:
>    call: rgl.init(initValue, onlyNULL)
>    error: OpenGL is not available in this build
> In addition: Warning messages:
> 1: Loading rgl's DLL failed.
> This build of rgl depends on XQuartz, which failed to load.
>   See the discussion in https://stackoverflow.com/a/66127391/2554330
> 2: Trying without OpenGL...
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list