R and RGtk2 in OSX Mountain Lion - r

Has anybody succeeded in installing this lately? I am aware of an existing thread that addresses this, but I haven't been able to make it work. Also, it's from 2010 so maybe there's a more up-to-date approach?
Specifically, I have tried to work with these:
R version 3.0.1 (2013-05-16) -- "Good Sport"
RGtk2_2.20.25
cairoDevice_2.19
GTK_2.18.5-X11
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin
echo $PKG_CONFIG_PATH
/usr/local/lib/pkgconfig:/usr/X11/lib/pkgconfig:
and following several instructions found online, but every time I try to:
R
>library(RGtk2)
I am always prompted with the error:
Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load
shared object
'/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so,
6): Library not loaded:
/Library/Frameworks/GTK+.framework/Versions/2.24.X11/Resources/lib/libgtk-x11-2.0.0.dylib
Referenced from:
/Library/Frameworks/R.framework/Versions/3.0/Resources/library/RGtk2/libs/RGtk2.so
Reason: image not found
Clues? Thanks a lot.

I solved it by installing GTK from http://r.research.att.com/libs/GTK_2.24.17-X11.pkg and XQuartz from https://www.xquartz.org/. Errors when loading rattle package can be solved in the same way.

Related

rJava doesn't load in R 3.4.2 and MacOS Sierra 10.12.6

Here's the error I get:
> library(rJava)
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/rJava.so
Reason: image not found
I see this is by no means a unique problem.. I've tried the solutions here, here and here. No success.
Some more details: I'm using R GUI, but I also can't load rJava through R terminal. I also didn't have any issue with rJava on R 3.3.s
You have two options here:
get older release of R and use precompiled version of rJava
get rJava sources and compile it for yourself
Note that rJava (most recent sources) require some features that are not embedded inside XCode and clang that is available via AppStore. You will need to do some low level stuff when it comes to building rJava package.
You can find detailed instruction here: http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/
If you decide to use older release of R, it's still a struggle to get it working, but way less to do: http://www.owsiak.org/r-java-rjava-and-macos-adventures/
JAVA_HOME path is different for different version of MAC OS.
In some cases there is /jre folder and in some cases it is not after /Home director manually go towards /server folder with CD command in terminal and using pwd copy the entire path use that to set the java.home then you can easily load rJava library. This is how I was able to fix the issue
options("java.home"="/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib")
Sys.setenv(LD_LIBRARY_PATH='$JAVA_HOME/server')
dyn.load('/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/lib/server/libjvm.dylib')
library(rJava)

How can I activate rJava on macOS?

> library('rJava')
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/rJava.so
Reason: image not found
I installed JDK9 version on my Macbook Pro
My OS is 10.12.6 Sierra
I tried to activate rJava many times.
I searched Google a lot.. but I could not solve that problem..
There are numerous issues you may find here.
incorrect rJava package
issues with JVM configuration
problems related to package sources (you need most recent release of clang to compile most recent version of rJava)
there are issues with R and it's configuration utility for JVM configuration.
In general, there is no easy solution you can apply for each and every environment. Take a look here:
http://www.owsiak.org/r-3-4-rjava-macos-and-even-more-mess/
I have collected sources of most of the issues you can find while working with JVM and R. Also, pay attention to JDK 9 - it no longer comes with JRE. In past, JRE was internal part of JDK.
In general, I don't think you can solve this issue without, at least, little bit of work.
For all the helping people with comments: "This link may provide ...". Just take a look at the content and you will know why I don't copy-paste it here ;)

R version 3.4.0 rgdal will not load

I recently installed the latest version of R (3.4.0) and installed all of my packages, but for some reason rgdal will not load and I'm getting this message:
library(rgdal)
Error: package or namespace load failed for ‘rgdal’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rgdal/libs/rgdal.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.4/Resources/library/rgdal/libs/rgdal.so, 6): Library not loaded: /Builds/unix/recipes/build/gdal-2.1.3-obj/libgdal.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.4/Resources/library/rgdal/libs/rgdal.so
Reason: image not found
I went to the rgdal/libs directory and the rgdal.so file exists, but for some reason doesn't want to load. Anyone else have this issue or a similar one?
Try installing RStudio and re-download it from there or type install.packages("rgdal"). If none of these work try installing another package and see if you can run it, because it is either the directory, the package or the version of the package is not compatible with the version of the language.
Do you have GDAL OS X frameworks installed? If not, go to William Kyngesburye's site, download and install frameworks in the following order:
GDAL Complete
GSL Framework
FreeType
cairo
After completing this installation, go for steps 2 and 3 of this answer, and then, install rgdal from R.app using these specifications in the install.packages command.
It solved the problem for me, hope it helps you!
Seems to be related to my issue posted same day, Unable to load pgirmess library ("image not found") - R 3.4 in Mac OS .
I installed the previous version of R from CRAN (3.3.3), and it works fine. You can have both versions installed at the same time. Maybe not a long term solution but at least a temporary fix so your work can continue.

Incompatible library version: libtk8.6.dylib requires ... when installing R package

I'm trying to install the R package ggplot2, though the error that I am getting seems unrelated to that specific package. I am running on Mac OSX 10.6.8. The error message is at the bottom of this message. What happened was:
I opened up R and typed install.packages("ggplot2"). After typing this, an X11 window opened saying that I should update to the latest version of X11. I clicked through and updated X11. The install went through fine, ending with a big green check mark.
Then, I thought, "let me check if R is up to date as well, as the ggplot documentation suggests updating R before installing ggplot". So I opened up R, and clicked "check for updates". Lo and behold! an update appeared. I downloaded and installed the update. The install went through fine, ending with a big green check mark.
When I opened R, I typed install.packages("ggplot2") and I got the message below:
> install.packages("ggplot2");
--- Please select a CRAN mirror for use in this session ---
Error: .onLoad failed in loadNamespace() for 'tcltk', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object
'/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.0/Resources/library/tcltk/libs/tcltk.so, 10):
Library not loaded: /usr/X11/lib/libfreetype.6.dylib
Referenced from: /usr/local/lib/libtk8.6.dylib
Reason: Incompatible library version: libtk8.6.dylib requires version 14.0.0 or later, but libfreetype.6.dylib provides version 13.0.0
Your help is greatly appreciated. Thanks.
Try installing the latest version of XQuartz. It worked for me.

Error when including the zoo package in R

When I tried to include the zoo package, I received the following error information:
> library(zoo)
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object
'/Users/zhangfan/Library/R/2.13/library/zoo/libs/i386/zoo.so':
dlopen(/Users/zhangfan/Library/R/2.13/library/zoo/libs/i386/zoo.so, 6):
Library not loaded: #rpath/R.framework/Versions/2.13/Resources/lib/libR.dylib
Referenced from: /Users/zhangfan/Library/R/2.13/library/zoo/libs/i386/zoo.so
Reason: image not found
Error: package/namespace load failed for 'zoo'
Could anyone explain what that means?
Thanks a lot!
I had the same error after trying to install zoo recently. I fixed it by installing from source.
install.packages("zoo", type="source", repos="http://cran.stat.ucla.edu/")
That looks a whole lot like the errors that Mac /User/'s were getting last week with the new GUI R.app that went along with R 2.14.0. Simon Urbanek fixed it several days ago, if those details fit your situation the first thing to try would be to install the new GUI from either CRAN or http://r.research.att.com/
If ion the other hand you are trying to install the new zoo-package from CRAN while running R 2.13.x you might want to upgrade R (at the same locations) to prevent major version mismatch.

Resources