我正在R Studio上的一个项目上工作,在Mac上安装qdap并运行库函数时收到错误消息。
这就是我所得到的。
install.packages('qdap')
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/qdap_2.3.0.tgz'
Content type 'application/x-gzip' length 4164745 bytes (4.0 MB)
==================================================
downloaded 4.0 MB
The downloaded binary packages are in
/var/folders/0v/c58lzwxd513g64xxc0gd85rm0000gn/T//RtmphbntNA/downloaded_packages
> library('qdap')
Error: package or namespace load failed for ‘qdap’:
.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.5/Resources/library/rJava/libs/rJava.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home/lib/server/libjvm.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
Reason: image not found
答案 0 :(得分:0)
我发现问题是R无法正确定位Java_home。
要遵循的步骤:
which java
Sys.setenv("JAVA_HOME" = 'your java location such as /usr/bin/java')
。