How to install tcltk in R? - r

My system is: debian6 + r-2.15.
I have installed tcl-devel and tk-devel with apt-get:
apt-get install tcl8.5-dev tk8.5-dev
But I'm getting the following error
> library("tcltk")
Error : .onLoad failed in loadNamespace() for 'tcltk', details:
call: fun(libname, pkgname)
error: Tcl/Tk support is not available on this system
In addition: Warning message:
S3 methods ‘$.tclvar’, ‘$<-.tclvar’, ‘as.character.tclObj’, ‘as.character.tclVar’,
‘as.double.tclObj’, ‘as.integer.tclObj’, ‘as.logical.tclObj’, ‘as.raw.tclObj’,
‘print.tclObj’, ‘[[.tclArray’, ‘[[<-.tclArray’, ‘$.tclArray’, ‘$<-.tclArray’,
‘names.tclArray’, ‘names<-.tclArray’, ‘length.tclArray’, ‘length<-.tclArray’,
‘tclObj.tclVar’, ‘tclObj<-.tclVar’, ‘tclvalue.default’, ‘tclvalue.tclObj’,
‘tclvalue.tclVar’, ‘tclvalue<-.default’, ‘tclvalue<-.tclVar’, ‘close.tkProgressBar’ were declared in NAMESPACE but not found
Error: package/namespace load failed for ‘tcltk’
> install.packages('tcltk')
Warning message:
package ‘tcltk’ is not available (for R version 2.15.1)
How can I install tcltk in my R?
Edit
> capabilities()["tcltk"]
tcltk
FALSE
I compiled R-2.15.1 to install it on debian6.04, but how can I do now in order to run tcltk?

I think you are doing this wrong.
Read the README at http://cran.r-project.org/bin/linux/debian/ to learn how to get the current R version for your Debian version (be it stable or testing). This version already has support for the tcltk package which comes with R, provided R is built the right way. Which is easiest to assure with a proper pre-built version.
You can check that by looking at capabilities():
R> capabilities()["tcltk"]
tcltk
TRUE
R>

I ran the following code on centos, You need to modify it according to your system.
First, install tcl and tk:
# on centos
sudo yum install tcl-devel tcl
sudo yum install tk-devel tk
Second, compile R with --with-tcltk:
./configure --enable-R-shlib=yes --prefix=`pwd` --with-x=no --with-tcltk
Third, install package.

Related

Can't install TTR (tseries) R 3.3.3 (on debian stretch)

I'm unable to install the tseries package into R version 3.3.3 (on Debian debian stretch 4.9.0-6) because of its dependence on TTR. When I run the install, it tries to compile TTR, which leads to the error message
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/home/moi/R/x86_64-pc-linux-gnu-library/3.3/curl/libs/curl.so':
/usr/lib/x86_64-linux-gnu/libcurl.so.4:version `CURL_OPENSSL_4' not found (required by /home/moi/R/x86_64-pc-linux-gnu-library/3.3/curl/libs/curl.so)
I did try installing a binary version of TTR using
install.packages("TTR", repos="http://R-Forge.R-project.org")
But that yield the error message package ‘TTR’ is not available (for R version 3.3.3)
The problem appears to be related a request for CURL_OPEN_SSL_4 from the R library curl.so. Since I have libcurl.so.4 installed, I don't understand what the problem is.
I'd appreciate any thoughts on how to resolve this.
thanks
I happen to (also) maintain r-cran-ttr for Debian and here is what I have in my Build-Depends in file debian/control:
Build-Depends: debhelper (>= 7.0.0), r-base-dev (>= 3.4.3), cdbs, \
r-cran-xts (>= 0.10-0), r-cran-zoo, r-cran-curl
So it looks like your r-cran-curl package needs re-installing. You may have the libcurl.so as a run-time dependency (from one or more packages, this is commonly used library) but to compile you need the built-time dependency commonly supplied by the matching -dev package.
So maybe try installing sudo apt-get install libcurl4-openssl-dev, then install package curl from CRAN and once that is there, install TTR from CRAN or R-Forge (which is likely a source install anyway).

installation of package ‘RCurl’ had non-zero exit status

I am trying to install RCurl on OS X 10.12.6 but get the following error:
Error: package or namespace load failed for ‘RCurl’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Users/nick/Library/R/3.4/library/RCurl/libs/RCurl.so':
dlopen(/Users/nick/Library/R/3.4/library/RCurl/libs/RCurl.so, 6): Library not loaded: #rpath/libcurl.4.dylib
Referenced from: /Users/nick/Library/R/3.4/library/RCurl/libs/RCurl.so
Reason: image not found
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/nick/Library/R/3.4/library/RCurl’
The downloaded source packages are in
‘/private/var/folders/hx/9xx9fwq91t95k45dzlmzxfy40000gp/T/Rtmp14zSi1/downloaded_packages’
Warning message:
In install.packages("RCurl") :
installation of package ‘RCurl’ had non-zero exit status
This error has been discussed a bit already, but the solutions are all specific to linux and I don't think they are relevant to OS X. I did try installing the homebrew version of curl but that didn't help.
Any ideas? I think that more debugging information would be helpful, but I'm not sure what else to provide.
Thanks in advance!
Nick
If someone face the same problem in Ubuntu just as I do, the solution is run first in terminal:
sudo apt-get install libcurl4-gnutls-dev
Then in R:
install.packages('RCurl')
Looks like it's expecting libcurl.4.dylib in your #rpath.
I think others have encountered the same issue so the solution should be in here somewhere:
brew unlink R solution
Install curl again
In case it is useful for anyone else with this issue, I solved it without having to install the cran binary of R. (I use the homebrew version because it allows you to use faster BLAS options that take advantage of parallelism). Steps were:
Make sure that R doesn't find the homebrew or anaconda versions of curl-config (this will only affect the current R session)
PATH=/usr/bin/:$PATH
Download and install latest version of RCurl from http://www.omegahat.net/RCurl/ (replace <RCURLVERSION> with the current latest version)
wget http://www.omegahat.net/RCurl/RCurl_<RCURLVERSION>.tar.gz
R CMD INSTALL RCurl_<RCURLVERSION>.tar.gz

ggplot2 sourcing error: X11 library is missing

I'm trying to load ggplot2 library for R.
1) I've installed ggplot2 by this command. It was installed with no errors
install.packages('ggplot2', dependencies = TRUE)
2) Then i'm trying to use
library(ggplot2)
and get an error
Error : .onLoad не удалось в loadNamespace() для 'tcltk', подробности:
вызов: fun(libname, pkgname) ошибка: X11 library is missing: install
XQuartz from xquartz.macosforge.org Ошибка: не удалась загрузка пакета
или пространства имен для ‘ggplot2’
3) Now i try to install XQuartz library by
install.packages("XQuartz")
and get this
Warning in install.packages : package ‘XQuartz’ is not available
(for R version 3.1.2)
My R version 3.1.2
OS X Yosemite 10.10.2
Can you help me in installing ggplot2 pls?
The OS update deleted the /usr/X11 and /usr/X11R6 symlinks. I had to just re-install XQuartz from macosforge which will setup the symlinks again.
I got the same error message about the missing library.
Nowadays, a lot of libraries can be installed with Homebrew. For this instance it would be:
brew cask install xquartz
Newer users of Homebrew may need this command:
brew install --cask xquartz
R opens graphics windows using the standard X11 library on Macs, which is no longer part of the standard MacOS. When you try running programs that open a graphics window, you will get a message: "Error in check_for_XQuartz(): X11 library is missing: install XQuartz from xquartz.macosforge.org" and it should work

Why does rJava not work on Ubuntu 14.04 using OpenJDK 7?

Hi I'm having issues with the rJava package from cran.
I have installed
sudo apt-get install openjdk-7-jdk
sudo apt-get install r-cran-rjava
and ran
sudo R CMD javareconf
# Java interpreter : /usr/bin/java
# Java version : 1.7.0_55
# Java home path : /usr/lib/jvm/java-7-openjdk-amd64/jre
# Java compiler : /usr/bin/javac
# Java headers gen.: /usr/bin/javah
# Java archive tool: /usr/bin/jar
I then try to run R and load rJava and get the following error:
R
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/lib/R/site-library/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or directory
Error: package or namespace load failed for ‘rJava’
I'm on Ubuntu 14.04 64 bit and am using R version 3.1.0 (2014-04-10) -- "Spring Dance"
UPDATE: Actually this is not specific to OpenJDK, I just tried oracle java 8 and got the same result. Also I found this workaround here which I am reluctant to use since it is indeed a workaround and doesn't really explain why it's necessary. The package system should have handled this in my opinion. Seems like libjvm.so is the problem and I have it located here
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/jamvm/libjvm.so
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so
/usr/lib/jvm/java-7-oracle/jre/lib/amd64/server/libjvm.so
and for some reason rJava fails to find them despite updating with sudo R CMD javareconf.
UPDATE 2: The plot thickens: If I run R as sudo it works.
Thankful for pointers.
you can solve this problem by opening rstudio in super user like
sudo rstudio
then inside R run
install.packages('rJava')
I had the same problem with a similar configuration (R 3.1.0, Ubuntu 12.10, 32-bit). I found the answer was in getting LD_LIBRARY_PATH set properly, as described here:
error: unable to load installed packages just now except that the subdirectory in question is 'client' not 'server'. So now I'm setting my environment like this:
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/i386:$JAVA_HOME/jre/lib/i386/client
I was able to solve this permanentelly using this answer: https://stackoverflow.com/a/25932828/3939832
This is usefull if you have Oracle java 7 or 8 installed. Exporting variables in my case was not a permanent solution. You should check what R is using as environment by doing:
Sys.getenv("JAVA_HOME")
and then you can use that environment by creating a java.conf file on /etc/ld.so.conf.d/ as stated in the above answer link.
if you are using oracle java then use following command :
sudo R CMD javareconf
won't help use:
sudo R CMD javareconf **JAVA_HOME**=(path where java home is located)
I tried many things but didnt worked. Then I tried using
sudo rstudio
and then
install.packages('rJava')
Its working. Coool
Installing the rJava package on Ubuntu is not quite as simple as most other R packages. Some quick notes on how to do it(Source: https://www.r-bloggers.com/installing-rjava-on-ubuntu/).
Install the Java Runtime Environment (JRE).
sudo apt-get install -y default-jre
Install the Java Development Kit (JDK).
sudo apt-get install -y default-jdk
Update where R expects to find various Java files.
sudo R CMD javareconf
Install the package.
> install.packages("rJava")
If you have a RStudio session open, then exit and restart it. This is important (a running RStudio session will not pick up these changes!).

Errors installing RForge version of xts package for R on OSX

The latest version of xts on CRAN is 0.7-5. But I'd like to try out the blotter package, for which xts >= 0.7.6.17 is required. To get this latest version, I first I downloaded the .tgz file from RForge and tried:
[Downloads]$ R CMD INSTALL xts_0.7-6.17.tgz
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...
* DONE (xts)
After launching R console, I typed require(xts) and got this:
> require(xts)
Loading required package: xts
Loading required package: zoo
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so, 6): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so
Reason: image not found
In addition: Warning message:
package 'xts' was built under R version 2.12.2
I reverted to the CRAN version by downloading that file and running this again:
[Downloads]$ R CMD INSTALL xts_0.7-5.tgz
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...
* DONE (xts)
Opening R console and typing in require(xts):
> require(xts)
Loading required package: xts
Loading required package: zoo
>
All is well again, except I need to RForge version to get blotter installed.
NOTE: I'm running OS X (10.6.6)
UPDATE: all is NOT well. Now I can't get the CRAN xts version to load properly.
UPDATE #2: I got my old xts back by running install.packages("xts", repo="http://cran.r-project.org"). Actually, I ran it for "quantmod" and "TTR" as well because all manner of mysterious breaking was occurring.
UPDATE #3: Following Dirk's recommendation in comments below, I've attempted to compile from source on OS X and was met with
make: gfortran: No such file or directory
So after installing from the link at http://www.macresearch.org/xcode_gfortran_plugin_update, I'm now faced with a new error complaining about the -arch flag:
gfortran -arch i386 -fPIC -g -O2 -c period.max.f -o period.max.o
f951: error: unrecognized command line option "-arch"
UPDATE #4: I installed the wrong fortran compiler in UPDATE #3. Don't use that compiler for R packages.
If you are using R on the Mac OS X platform, then it's good to know the mechanics of installing from source, as Mac binaries are sometimes slow to make it to repositories. The R eco-system is Ubuntu and SVN. Someday it may morph to OS X and Git (we can hope, no?)
Before you start installing from source, you need to make sure you have Xcode installed.
http://developer.apple.com/technologies/tools/xcode.html
Then you need to have a fortran compiler, which doesn't come with Xcode. The good news is that there is a place devoted to fortran compilers on OS X for R users.
http://r.research.att.com/tools/
Once this is installed and configured properly, you need to get the cutting-edge version of xts from RForge from here: (Thanks Dirk)
http://r-forge.r-project.org/src/contrib/xts_0.7-6.17.tar.gz
Finally, simply run the following from command-line in terminal:
[Downloads]$ R CMD INSTALL xts_0.7-6.17.tar.gz
NOTE: tar.gz is the extension for source files while .tgz is the extension for Mac binaries.

Resources