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? Can you suggest me a helpfile/documentation to read to get into understanding this? Is there an index of the R C-exports/keywords to look up these things? I've been digging in the sources, but I thought there may be a better way....? I've been able to extract all the exported symbols from the R.dll, but without arguments types (and of course without descriptions ...) 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? Thanks for any suggestions Peter
Peter, On 18 June 2008 at 14:13, Peter.Peyk at unibas.ch 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.
Hi Peter Just a note on the SETCAR, SETCADR, macros etc. - if you look at an introductory Lisp or Scheme tutorial, you will see the origins of these names, and hopefully their behaviour will make sense ;-) Cheers Rory *********************************************************************************** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. The Royal Bank of Scotland plc does not accept responsibility for changes made to this message after it was sent. Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by The Royal Bank of Scotland plc in this regard and the recipient should carry out such virus and other checks as it considers appropriate. Visit our websites at: www.rbs.com www.rbs.com/gbm www.rbsgc.com *********************************************************************************** ______________________________________________________________________ This email has been scanned by the MessageLabs Email Security System. For more information please visit http://www.messagelabs.com/email