[R] returning strings to R from C functions

Wolski wolski at molgen.mpg.de
Thu Jun 3 08:57:23 CEST 2004


Hallo!

There is a package called BioSeq1 at bioconductor. It Is using the .C interface and was doing a lot of string manipulation. Should have tons of examples. 

The simplest way to do it is. 
You my alloc fist the char in R.

mychar<-paste(rep(" ",1000),collapse="")


tmp<-.C(
as.character(mychar)
nchar(mychar)
)

You can write into the char on the C side what you like. The char will be in tmp[[1]]

 
Sincerely Eryk





*********** REPLY SEPARATOR  ***********

On 6/2/2004 at 11:22 PM Fernando Pineda wrote:

>I'm using .C() and .External() and have no problems sending integers, 
>reals or strings from R to C. Nor do I have problems sending integers 
>or reals back from C to R. But I'm pulling my hair out trying to set 
>a string value in a C function and then sending it back from C to to 
>R. I've searched the usual sources and tried various casts, macros 
>and allocation schemes, but I'm failing miserably. Could someone 
>please put me out of my misery and point me to a working example?
>
>Thanks,
>
>-- Fernando
>-- 
>Fernando Pineda
>Associate Professor
>Dept. of Molecular Microbiology & Immunology
>Johns Hopkins Bloomberg School of Public Health
>Room E5146
>615 N. Wolfe St., Baltimore, MD 21205-2179
>fernando.pineda at jhu.edu
>443-287-3673 (office)
>410-955-0105 (fax)
>http://www.pinedalab.jhsph.edu
>
>______________________________________________
>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



Dipl. bio-chem. Eryk Witold Wolski    @    MPI-Moleculare Genetic   
Ihnestrasse 63-73 14195 Berlin       'v'    
tel: 0049-30-83875219               /   \    
mail: wolski at molgen.mpg.de        ---W-W----    http://www.molgen.mpg.de/~wolski




More information about the R-help mailing list