[R] Calling C++ code fom R --How to export C++ "unsigned" integer to R?

From: Boom 2k1 <boom2k1_at_hotmail.com>
Date: Tue 09 May 2006 - 04:44:28 EST


Hello all,

Is there a way to export C++ "unsigned" integer to R? (I am trying to parse files in "BPMAP" format, and some variables are of type unsigned int (first declared in C++) ).

I know that to export signed integer to R, I can do the following in C++:

int Some_INTEGER = 5;

int *p_myInt;
SEXP myInt;
PROTECT(myInt=NEW_INTEGER(1));

myInt[0] = Some_INTEGER;

UNPROTECT(1); return myInt;

However, it appears that myInt is a signed integer.

I have looked over Rdefines.h and it does not look like there is a definition for NEW_UNSIGNED_INTEGER !

How would I export an unsigned integer to R?

obviously this won't work:

unsigned int Some_INTEGER = 5;

unsigned int *p_myInt;
SEXP myInt;
PROTECT(myInt=NEW_INTEGER(1));

myInt[0] = Some_INTEGER;

UNPROTECT(1); return myInt;

This would give me a casting error!

How should I get around with this?

Thanks!

Charles Cheung



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue May 09 04:49:35 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 May 2006 - 06:10:05 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.