Install R develop version and RPy2 on CentOS 5.5

Prepare the environment

Before configure and compile R source code, I did the following updating of CentOS in order to support R capabilities by installing these packages:

[sourcecode language=""]
libtiff libtiff-devel
libpng libpng-devel
libjpeg libjpeg-devel
cairo cairo-devel
libX11 libX11-devel
libXt ibXt-devel
readline readline-devel
[/sourcecode]

and in order to produce the pdf version of the R-manual, I also installed all search results of

[sourcecode language="bash"]
yum search tetex except tetex-doc
[/sourcecode]

The RPy2 requires that you enabling R-shlib when you install R package. To do so you can build your own R package from source code.

1. donwload R source code: from http://cran.r-project.org/src/base/R-2/

[sourcecode language="bash"]
./configure --enable-R-shlib
[/sourcecode]

Here are my configuration results:

[sourcecode language=""]
R is now configured for x86_64-unknown-linux-gnu
Source directory:          .
Installation directory:    /usr/local
C compiler:                gcc -std=gnu99  -g -O2
Fortran 77 compiler:       gfortran  -g -O2
C++ compiler:              g++  -g -O2
Fortran 90/95 compiler:    gfortran -g -O2
Obj-C compiler:
Interfaces supported:      X11, tcltk
External libraries:        readline
Additional capabilities:   PNG, JPEG, TIFF, NLS, cairo
Options enabled:           shared R library, shared BLAS, R profiling, Java
Recommended packages:      yes
configure: WARNING: inconsolata.sty not found: PDF vignettes and package manuals will not be rendered optimally (as for this warning, specific fonts is not found.)
[/sourcecode]

 

2. Continue the following steps to complete installing R

[sourcecode language="bash"]
make
make check
make install
[/sourcecode]

some other errors you may encounter:

[sourcecode language=""]
configure: error: no acceptable C compiler found in $PATH  --install gcc gcc-c++
configure: error: No F77 compiler found --install compat-gcc-34-g77 gcc-gfortran
configure: error: --with-x=yes (default) and X11 headers/libs are not available  --install libXt-devel
[/sourcecode]

 

3. Install RPy2:

[sourcecode language="bash"]
/opt/python2.7/bin/easy_install rpy2
[/sourcecode]

You could use python2.7 if you have made a symbolic link in /usr/bin/python2.7 by

[sourcecode language="bash"]
ln -s /opt/python2.7/bin/python /usr/bin/python2.7
[/sourcecode]

** I had encountered a problem showing that lpython2.7 cannot be found, to solve this problem I created a symbolic link

[sourcecode language="bash"]
cd /usr/lib64
ln -s /opt/python2.7/lib/libpython2.7.so.1.0 libpython2.7.so.1.0
ln -s libpython2.7.so.1.0 libpython2.7.so
[/sourcecode]

If you have more than one R package installed on your system you may encounter some errors, like "rpy2.rinterface.baseenv.get("show") show not found" when you try to use the rpy2 package.

solution:
configure the  /etc/ld.so.conf.d/R-x86_64.conf file, create the file if the file does not exist Put the path of the R package whic you used to build your rpy2 into this file. Mine is /usr/local/lib64/R/lib.

Run /sbin/ldconfig
You may solve the problem by now.

3. install libraries in R

[sourcecode language="bash"]
sudo  R
install.packages('package_name')
[/sourcecode]

pay attention to the location of the installation of new packages "/usr/local/lib64/R/library/e1071/libs"
Sometimes when you install a package and it requires at least certain version of the R, you could download the source code of the package and do the following installation:

[sourcecode language="bash"]
install.packages("/path/to/the/packages/source/file", repos=NULL, type="source")
[/sourcecode]

6 comments:

  1. Thanks for posting this! I've been pounding my head against this exact problem for a couple hours and this fixed it.

    ReplyDelete
  2. Thanks for your comment. Good to know it helps.

    ReplyDelete
  3. This is awesome :) Thanks!

    Was stuck on this for a day.

    ReplyDelete
  4. Thank you very much! Couldn't find the right packages to install anywhere else

    ReplyDelete
  5. Thanks a lot. It helped me a lot :)

    ReplyDelete

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...