[Rcpp-devel] [R] Plot and curve inside C++

Dirk Eddelbuettel edd at debian.org
Sun Mar 6 17:53:24 CET 2011


On 6 March 2011 at 16:45, Paul Smith wrote:
| On Sun, Mar 6, 2011 at 2:53 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
| > |
| > | I would like to use
| > |
| > | - plot,
| > | - curve
| > |
| > | inside a C++ program. What R package do you recommend? Rcpp?
| >
| > You can use base R, embedding R is explained in the 'Writing R Extensions'
| > manual.  That said, the material is a little on the advanced side.
| > Rcpp and RInside try to provide an easier API, and some users find it
| > helpful.
| >
| > As for your question, I am committing the code below as rinside_sample11.cpp
| > in the examples/standard/ directory of RInside. With the generic Makefile in
| > that diretory, you just say 'make' and the rinside_sample11 binary results
| > (as do all the other examples and tests there).
| >
| > I hope you find it mostly self-explanatory, if not please come to the
| > rcpp-devel list for help.
| 
| Thanks, Dirk. I have tried your example, and I can say that it works
| fine. 

Great, always a pleasure to hear that.

| However, I would like to plot graphs from inside a C++ project.
| Thus, I would like to know what include paths and libs should I add to
| my C++ project. I am using QtCreator as an IDE on Fedora 14.

You need to read the Makefile that supports these example and understand what
it does.  You then need adapt your .pro file for Qt accordingly as it will
create your Makefile. QtCreator is just a shell / ide and I fear you still
need to work out how to do this. If you want something truly portable you
have to do what the makefile does and compute locations for R, Rcpp and
RInside on the fly.  If you don't need portability you can hardcode the
paths.  If you're completely lost try reducing things to a simple example of
one main() function with one widget displaying the png we created. I can try
to help you from there as I had a bit of Qt / qmake experience.

Also, the vignette Rcpp-package explains how to use Rcpp in your own packages
and may be of help too.

Hope this helps, Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list