How to set up Eclipse + StatET + Rcpp on Windows

巧了我就是萌 提交于 2019-12-12 08:33:09

问题


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.


回答1:


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.

  1. 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.

  2. 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"

  3. (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.

  4. 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;

  5. If you don't have Eclipse yet, please install it with CDT If you have it already, make sure you have installed CDT plugin.

  6. 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.

  7. 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.

  8. 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.

  9. 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.




回答2:


You can use a packaged installation of Eclipse and R called Architect from Openanalytics.



来源:https://stackoverflow.com/questions/12886517/how-to-set-up-eclipse-statet-rcpp-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!