Thursday, October 30, 2014

R, packages and Rstudio install on Debian wheezy

See also my previous post on Debian GNU-Linux installation on a Lenovo T400.

R install

I used the Synaptic package manager to add the R repository for Debian from a nearby mirror, under : settings / repositories / other software / add.
Add this APT line:
deb wheezy-cran3/

There was an error:
W: GPG error: wheezy-cran3/ Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 06F90DE5381BA480
After looking at several forums, and this stackoverflow question, I installed debian-keyring and added the key with the commands:
gpg --keyserver --recv-key 06F90DE5381BA480
gpg -a --export 06F90DE5381BA480 |sudo apt-key add -
I could then install R version 3 from the synaptic package manager.


I downloaded R-studio and installed it. There was a missing dependency for libjpeg62. I installed that package from Synaptic. Then ran the dpkg command to install rstudio.
dpkg -i rstudio-0.98.507-i386.deb


Then I installed Git in order to clone my R project from an online repository.
git clone  project_repository_url


Within Rstudio, I installed a few packages:
install.packages(c("plyr", "reshape2", "ggplot2"))
install.packages(c("xtable", "markdown", "devtools"))


The devtools packages requires a libcurl dev Debian package. You can install it at the shell prompt:
$ sudo apt-get install libcurl4-gnutls-dev
Back at the R prompt
Other dependencies might be needed, the RStudio page on devtools recommends installing the Debian package r-base-dev.


The dplyr package required the latest version of a Rcpp package. Which was not available on my CRAN mirror. I installed it from source, (based on this message):
install.packages("Rcpp", type = "source")


The xlsx package installation complained:
configure: error: Cannot compile a simple JNI program. See config.log for details.
Make sure you have Java Development Kit installed and correctly registered in R.
If in doubt, re-run "R CMD javareconf" as root.

Required the latest version of java 7. (inspired by this post). I installed openjdk-7 from the synaptic package manager. Then ran

update-alternatives --config java  # Choose java 7 as the default
R CMD javareconf
install.packages("xlsx") # worked


MySQL client and server are installed on my system.
While installing RMySQL, I struggled with a configuration error:
  could not find the MySQL installation include and/or library
  directories.  Manually specify the location of the MySQL
  libraries and the header files and re-run R CMD INSTALL.
This post has an answer (thanks!):
sudo apt-get install libdbd-mysql  libmysqlclient-dev
That fixes the issue!
I can connect to the database
mychannel <- br="" dbconnect="" host="localhost" user="paul" ysql="">                       password="***", dbname="dbname")

R packages which are better installed from the Debian package manager

Some packages, such as ‘minqa’, ‘SparseM’ and ‘car’ return an error when one tries to install them from the R prompt. The can only be installed from the Debian package manager, where they have names starting with "r-cran": "r-cran-car", "r-cran-sparsem", "r-cran-minqa".

Ready to work!

1 comment:

Diego Salinas said...

Thanks, i was looking for somenthing like this!

ps: my version of Debian is Jessie 8.2, and it work perfect.