Error: package or namespace load failed for ‘matlib’ - r

I am getting this error everytime I run library(matlib): Error: package or namespace load failed for ‘matlib’: .onLoad failed in loadNamespace() for 'rgl', details: call: rgl.init(initValue, onlyNULL) error: OpenGL is not available in this build
library(matlib)
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 '/Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so':
dlopen(/Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so, 6): Library not loaded: /opt/X11/lib/libGLU.1.dylib
Referenced from: /Users/nupur/Library/R/x86_64/4.1/library/rgl/libs/rgl.so
Reason: image not found
Warning: 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
Warning: Trying without OpenGL...
Error: package or namespace load failed for ‘matlib’:
.onLoad failed in loadNamespace() for 'rgl', details:
call: rgl.init(initValue, onlyNULL)
error: OpenGL is not available in this build

Running this before library(matlib) worked for me:
Sys.setenv(RGL_USE_NULL=TRUE)

Related

Unable to load RWeka package

I have tried adding the path in the terminal using the solution given here and it said was successfully added but still I am unable to load the RWeka package.
It is giving me the below error -
Error: package or namespace load failed for ‘RWeka’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rJava/libs/rJava.so, 6): Symbol not found: _EXTPTR_PTR
Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rJava/libs/rJava.so
Expected in: /Library/Frameworks/R.framework/Resources/lib/libR.dylib
in /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rJava/libs/rJava.so
In addition: Warning message:
package ‘RWeka’ was built under R version 4.0.2
What could be done? Please Help!

‘rJava’ could not be loaded after installing R version 3.4

Loading required package: xml2
Loading required package: rJava
Loading required package: methods
Error: package or namespace load failed for ‘rJava’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/r Java.so
Reason: image not found
Error: package ‘rJava’ could not be loaded
Execution halted
I'm getting this error a day after I installed version 3.4 of R. I tried solutions from other pages but it didn't work. I can't run R scripts through the terminal but I run scripts on RStudio. I'm thinking that it might be a problem with paths, but I just wanted to double check here and confirm instead of getting myself into a deeper mess.

Issues with loading XLConnect library in R

I have installed XLConnect package though my R studio. When I try to load the library I get the following error
> library(XLConnect)
Loading required package: XLConnectJars
Error: package or namespace load failed for ‘XLConnectJars’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: image not found
Error: package ‘XLConnectJars’ could not be loaded
I checked the /Library/Frameworks/R.framework/Versions/3.4/Resources/library folder and I am noticed all three mentioned libraries(XLConnect, XLConnectJars, rJava) already present.

R library(FSelector) failed to run due to java error

I have been trying to get FSelector from MLR package working recently, but have been running into the same java issue on my mac:
Error: package or namespace load failed for ‘FSelector’:
.onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: #rpath/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rJava/libs/rJava.so
Reason: no suitable image found. Did find:
/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libjvm.dylib: mach-o, but wrong architecture
/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries/libclient.dylib: mach-o, but wrong architecture
Does anyone know how to fix the issue? Thanks!

Can't load any packages in RStudio

I'm very new to R and I'm having problems right off the bat. None of the packages want to load and each time I try, the same error message is being given (see below). What am I doing wrong? Thanks in advance for any help!
library(xlsx)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: fun(libname, pkgname)
error: JAVA_HOME cannot be determined from the Registry
Error: package ‘rJava’ could not be loaded
I have since added JAVA_HOME to my environmental variables but now when I attempt to load a package, a new error pops up (See Below)
library(xlsx)
Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: inDL(x, as.logical(local), as.logical(now), ...)
error: unable to load shared object 'C:/Users/Sam/Documents/R/win-library/3.3/rJava/libs/x64/rJava.dll':
LoadLibrary failure: %1 is not a valid Win32 application.
Error: package ‘rJava’ could not be loaded

Resources