When I came to know that I can create a R package with C++ using Rcpp, I was excited about it and eager to know development environment for it. And thanks to Fell Stat Blog, I could quickly establish a great environment using Eclipse with StatET, its plugin for R, to use Rcpp and RInside (another package for embedding R into your C++ application) on Windows.
Since the blog was, however, based on OS X, several things required trial & error (& almost give-up) to adjust for Windows - it took me 6 hours of my leisure time. For example, you need to install Rtools to be able to compile C/C++ using R CMD statements and Miktex to convert your Rd files to pdf file. In addition, build settings are different from OS X.
In order to save others from possible trial & error period I've experienced, I made this wiki on Eclipse + StatET + Rcpp on Windows. Feel free to make comment or another answer. Otherwise, enjoy this great open source environment for analytical software development you can get.
UPDATE (late 2016): Few years ago, I changed IDE for R from Eclipse to RStudio and I recommend it for everyone using R and Rcpp.
For this wiki, I will proceed my talk based on the latest version of R, R 2.15.1 and this is the list of steps you need to follow.
If you have already installed R in your Windows system, make sure its path does not include space such as "C:\Program Files\R\R-2.15.1". If so, there is nothing you can do but reinstall your R system to a directory such as "C:\R\R-2.15.1". If you don't do that, Rcpp or RInside will not work on your system.
Install Rtools (Rtools2.15.1 in this case) This installer includes basic tools to run R CMD and related things and gcc compiler. I installed this into "C:\Rtools"
(Optional) You can install MikTex to automatically generate pdf file from your Rd files when R CMD check executed. Make sure <Miktext installation directory>\miktex\bin
is in your system path.
Include following directories into your system path. This is important. Otherwise, most of them here will not work.
C:\Rtools\bin;
C:\Rtools\gcc-4.6.3\bin;
C:\R\R-2.15.1\bin\i386;
If you don't have Eclipse yet, please install it with CDT If you have it already, make sure you have installed CDT plugin.
Now it's time to install an Eclipse plugin for R, StatET As the web site suggested, I used http://download.walware.de/eclipse-3.8
to install it. After that, ran R windows and installed Rj install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-1.1")
After that, you are done with installing StatET. In Eclipse, follow Cheatsheet of StatET to make yourself familiar with the environment. Especially, create R environment, R console configuration, external configuration for R CMD check, build, install so you can run R and its CMD in Eclipse.
It's time to install Rcpp and RInside. As Fell Stat recommended, I used following in R console in Eclipse to do that. install.packages(c("Rcpp","RInside"),type="source")
This will get source of Rcpp and RInside from internet and compile them before installing them. If you get any error message here, it's good time to check you followed everything I described above. In my case, I got some when I didn't set system path right or when my R path included space.
Now it's time to examine the environment with a test project. For this, I recommend you read step 4, 5, 6, 7 of Fell Stat Blog. One thing I recommend is that when you create a sample project, use
Rcpp.package.skeleton("MyCppPackage", module=TRUE)
That way, you would experience power of Rcpp with Rcpp modules.
As I said, in #7, some settings are different from OS X on Windows. I will just display my setting here on images. Here, I didn't set directories for RInside, but I hope you can easily figure this out from Rcpp setup.
Hope this helps. Enjoy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With