From noah78 at web.de  Tue Jul 18 14:20:18 2006
From: noah78 at web.de (=?UTF-8?Q?J=C3=B6rn_Schulz?=)
Date: Tue, 18 Jul 2006 05:20:18 -0700 (PDT)
Subject: [Rd] send a list from R to C
Message-ID: <5377049.post@talk.nabble.com>


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)));
}

where

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.



[Rd] send a list from R to C
=?UTF-8?Q?J=C3=B6rn_Schulz?=