Integrating R and C++ ( Installing Rcpp package on Windows and Centos5)

1,513 views
Skip to first unread message

$hekhar

unread,
Apr 18, 2011, 5:00:35 AM4/18/11
to Bangalore R Users - BRU
Many of my friends asked me to integrate the R with C/C++. so here
goes first the installation part on windows and as well as on linux
( I have tried only on CentOS, i think it must be more or less same on
*nix flavours)

The next post will be on working of Rcpp package and developing
applications based on it.

I am using 2.1.2.0 version of R on both windows and CentOS.

1. Installing Rcpp on CentOS:

(A) Download the Rcpp package from http://cran.r-project.org/web/packages/Rcpp/index.html

(B) Untar the contents by the command:
tar-xvf Rcpp_0.9.4.tar.gz
it will create the folder "Rcpp"

(C)Now run the command R CMD INSTALL Rcpp

(D)To check whether this package has been added to R or not, open the
R console and type the command installed.packages(),it gives the list
of packages which is included in R. it must show you Rcpp package.

(E)Open the R console and check whether Rcpp library is properly
uploaded in the R environment or not, by typing the command
library(Rcpp), it shouldn’t throw any error.


2. Installing Rcpp on windows:

It is little bit tricky to install Rcpp on windows. if you get the
binary package then you are lucky, you can directly add it to the
library directory of R and it gets added.
You can check whether the library is installed or not by typing the
command installed.packagess()

But to be on safer side, i suggest you to do the following:

(A) Are you able to run R from command prompt? if yes then no problem,
but if "NO" then follow the steps below:

(i) While installing R, make sure the installation directory path
does not contain any spaces.
if any spaces are there in the path , then it wont run the R command
(ii) Okay you have no spaces in the installation path where R is
getting installed. Now add the installation path to the PATH
environment variable. For example: D:\ProgramFiles\R\R-2.12.0\bin
\i386, i have added to the PATH environment variable.

Now run the R from the command prompt, it should start the R console.

(B) Download the Rcpp binary package for windows from
http://cran.r-project.org/web/packages/Rcpp/index.html and unzip the
contents.

(c) Put the Rcpp directory into the library directory of R.(D:
\ProgramFiles\R\R-2.12.0\library)

You can either open the console or from the command prompt itself type
library(Rcpp) you will see the warning that Rcpp has been built on R
version 2.13.

Hope that helps. The next post will be on working of Rcpp and some
sample applications.

Regards,
Som Shekhar


$hekhar

unread,
Apr 18, 2011, 5:45:27 AM4/18/11
to Bangalore R Users - BRU
Sorry the R version is 2.12.0.

Regards,
Som shekhar

On Apr 18, 2:00 pm, "$hekhar" <shekhar2...@gmail.com> wrote:
> Many of my friends asked me to integrate the R with C/C++. so here
> goes first the installation part on windows and as well as on linux
> ( I have tried only on CentOS, i think it must be more or less same on
> *nix flavours)
>
> The next post will be on working of Rcpp package and developing
> applications based on it.
>
> I am using 2.1.2.0 version of R on both windows and CentOS.
>
> 1. Installing Rcpp on CentOS:
>
> (A) Download the Rcpp package fromhttp://cran.r-project.org/web/packages/Rcpp/index.html
> (B) Download the Rcpp binary package for windows fromhttp://cran.r-project.org/web/packages/Rcpp/index.htmland unzip the

Shekhar

unread,
Apr 19, 2011, 1:48:25 AM4/19/11
to Bangalore R Users - BRU
Sorry for the typos::

The command is installed.packages() not installed.packagess()
> > (B) Download the Rcpp binary package for windows fromhttp://cran.r-project.org/web/packages/Rcpp/index.htmlandunzip the
Reply all
Reply to author
Forward
0 new messages