[R] Interfacing pre-existing C++ library from R

Alexander Duering alexander.duering at db.com
Mon Feb 25 17:50:36 CET 2002


Hello,

I'm trying to link a large in-house C++ library into R. So far, I've managed to to most of what I want, but I have one remaining question and a suggestion.

The suggestion first: I've found it useful to put

     #ifdef __cplusplus
     extern "C" {
     #endif

and
     #ifdef __cplusplus
     }
     #endif

around the function prototypes in Rinternals.h (in /usr/local/lib/R/include on my Red Hat 7.2 box) so my dynamic linker would no longer complain about mangling-related undefined symbols. Also, I had to use #define USE_RINTERNALS before including them in order to get a few macros I suppose are natural to use. To be honest, I do think the include files could do with a bit of cleaning up, in particular in view of linking in C++ code, but no complaints (I'm very happy to have R as it is).

My question is this: Our library makes extensive use of matrices of mixed type, i.e., I would need to pass in and out objects that are logically of rectangular structure, but some cells contain numbers, others strings. I had initially hoped to be able to use data frames for that, but I realise that columns have to be of identical mode. I could, if nothing else works, use string matrices, but that would be very very unsatisfactory (and take ages, because I'd have to check, and possibly convert, each matrix element). Could somebody please suggest the 'natural' R data structure for this kind of object? I'm using cell arrays in Matlab and lists of lists in Perl for that purpose, if it's any help.

Many thanks,

Alex



--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list