[Rd] send a list from R to C

From: Jörn Schulz <noah78_at_web.de>
Date: Tue 18 Jul 2006 - 12:20:18 GMT

Hello at all !

What is the correct form to give a list form R (e.g. list(c(-1,1), "TestFile") ) to C. I have no problems, if I don't use character and I have also no problems to give a character vector form R to C. But, if I combine real and strings in a list then I don't know the correct syntax.

I try it with following (an example):

SEXP writeFile(SEXP headerR){
Image *SaveImage;

PROTECT(headerR = AS_VECTOR(headerR));
SaveImage->Xmin = (float) REAL(VECTOR_ELT(headerR, 0))[0];
SaveImage->Ymin = (float) REAL(VECTOR_ELT(headerR, 0))[1];
strcpy(SaveImage->Description, CHAR(STRING_ELT(headerR, 1))); }


typedef struct {
  float Xmin;
  float Ymin;
  char Description[80];
  } Image;

But with this form the characters are doesn't correct (in this case Description). Perhaps a problem is that I protect the list with AS_VECTOR. Or is it not possible to comitted a list from R to C that contain numeric values and characters ?

View this message in context: http://www.nabble.com/send-a-list-from-R-to-C-tf1960161.html#a5377049
Sent from the R devel forum at Nabble.com.

R-devel@r-project.org mailing list
Received on Tue Jul 18 22:25:57 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 18 Jul 2006 - 14:30:49 GMT.

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