I have been strugling to get character data in and out of c functions
using the .Call() interface, but I don't succeed getting them back
into R.

The example:

#include "R.h"
#include "Rdefines.h"

char *cp = "xxxyyyy";
SEXP do_char(SEXP c) {
   int i;
   SEXP s;

   for (i = 0; i < LENGTH(c); i++)
       printf("%d:[%s]\n", i, CHARACTER_DATA(STRING_ELT(c,i)));
       /* CHARACTER_VALUE() does not work here! */
   s = NEW_CHARACTER(1);
   CHARACTER_POINTER(s) = cp;
   c = NEW_CHARACTER(3);
   SET_STRING_ELT(c,0, s);
   SET_STRING_ELT(c,1, s);
   SET_STRING_ELT(c,2, s);
   return c;
}

works only for the first half; but I can't manage to fill the string
and return it back.

Note that I had to use CHARACTER_DATA instead of CHARACTER,
which Thomas Lumley suggested last Saturday.
--
Edzer

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to