简体   繁体   中英

R and C++ using RStudio

On Nov 29, 2012 a new version of RStudio released that makes it possible to " write C++ functions and simply source them into R just as you'd source an R script " . I became super-interested thinking that similar to integration of knitr and Latex into RStudio which enables me to use RStudio for both my R programs and Latex codes, the new version enables me to do the same with my C++ codes. I'm beginner in C++ and I thought that now that Rstudio has made it easy to program in C++ and source it in R, it's a great time to start learning C++ which I really need for my project involving heavy computations. After downloading the new version and creating a new .cpp file and writing a simple C++ code, I'm not able to compile it. Would you please guide me on:

1) Whether the new RStudio can be used as an editor for writing and running my C++ codes instead of Visual Studio or other editors/IDEs?(Similar to what I do with my Latex codes)

2) If so, I assume that I need to set up C++ compiler separately, would you guide me on how to do that in mac?

3) like loading knitr package, do I need to load any package in R to be able to source/or run my C++ codes in Rstudio?

3) Finally, do I need to set the RStudio preferences to be able to compile my C++ codes directly from RStudio?

Quick ones regarding your questions:

  1. No, RStudio is unlikely to become your IDE for standalone C++ programs, though it does provide an editor and you can tailor Makefiles...
  2. This is well documented in numerous tutorials on the web, and of course the R documentation (see Writing R Extensions . It is a little rude of you to expect us to retype it all for you here. Also see the documentation on the RStudio site.
  3. Yes, you need the Rcpp package for this.
  4. (Your counting is off.) The question does not make sense to me as asked. If you get 1) to 3) sorted out, things may become clearer.

Try Google, RSeek.org and the SO search features. These questions have all been asked, and answered, before.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM