Passing characters by .Call
Hi! Thank a lot! Its what I was looking for. Eryk. *********** REPLY SEPARATOR ***********
On 2/3/2004 at 5:02 PM Roger Bivand wrote:
On Tue, 3 Feb 2004, wolski wrote:
Hi! I try to pass a character by the .Call interface to an c function. And
to cast it into a
char *ch; Is it possible to do it and how?
Yes. First make sure you have your "Writing R Extensions" handy. Next decide whether you are going to use Rdefines.h or Rinternals.h. Then read the chosen header file (in R/includes/). (Rdefines.h includes Rinternals.h). For example line 255 in Rinternals.h gives #define STRING_ELT(x,i) ((SEXP *) DATAPTR(x))[i] I have used incantations like CHAR(STRING_ELT(x, 0)) where x is a character vector - be prepared to use Rprintf() to check that your assignment works out.
Eryk
______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html -- Roger Bivand Econonic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway, voice: +47-55959355, fax: +47-55959393; Roger.Bivand at nhh.no
Dipl. bio-chem. Eryk Witold Wolski @ MPI-MG Dep. Vertebrate Genomics Ihnestrasse 73 14195 Berlin 'v' tel: 0049-30-84131285 / \ mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski