Hi Dirk,

I've had a closer look now at Rcpp and I've found a lot
of constructors and functions that take SEXPs as input - so the way back from
R to C++ seems clear to me.

However, I don't know how to pass my data from c++ to R . I've managed
to have the embedded R evaluate commands (construct vectors and do something with them) with the help of the official manual, but I couldn't assign for instance an RcppVector to an SEXP or any of these constructed vectors ... The only clue I had is the dataframe that is constructed in the included Rcpp example - but it's used only with a custom made function - not with standard R functions which would be my goal with the ANOVA.

Thanks for your help!!!
Peter






Peter,

On 18 June 2008 at 14:13, [EMAIL PROTECTED] wrote:
| Hi R-Developers,
|
| I'm working on running statistical analyses with embedded R from a
| Qt-GUI-application (C++).
|
| I've been able to link with R libraries, but I'm having a hard time to
| understand the C-coding examples. I'm a C++, not a C programmer (never
| used malloc before), and many of the R-specific
| functions/keywords/macros (for instance (UN)PROTECT, SETCAR, all the
| data types (SEXP, CHARSXP etc..) ) don't mean anything to me. The
| section on the SEXP type in the R-internals doc didn't tell me much.
| How can I create such objects containing my data? how can I extract
| numbers or strings from SEXPs?

Have a look at RCpp at http://r-forge.r-project.org. While initially written
for accessing C++ from R, it works perfectly well the other way too.  Thanks
to a number of (templated) classes, it abstracts away a lot of the underlying
C representation.

I also use for embedded R inside of C++.

[...]

| My goal is to prepare some data for R to run an ANOVA on, run it, and
| retrieve the results to display them on the GUI. Can you suggest me a
| helpfiles/documentations to read for this?

That should work just fine. One of my apps at work gathers simulation data in
STL vectors of vectors, passes that to an R matrix via one RCpp invocation. I
then assign that object to an R object in the embedded R instances, and let R
run analysis on it.  Much nicer / easier than going the old route of export
to csv, calling R, reimportting, ....

Hth, Dirk

--
Three out of two people have difficulties with fractions.


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to