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> /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@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.