[R] .C() memory allocation

Douglas Bates bates at stat.wisc.edu
Fri Dec 5 21:12:29 CET 2003


Dan Davison <davison at uchicago.edu> writes:

> I would like to retrieve a vector of integers from a call to .C(), but I
> don't know its length in advance. How do I do this without making an ugly
> safe guess?
> 
> My vector is called "sequences".
> I am passing the argument sequences = integer(0) in the call to .C(),
> then declaring the corresponding argument as int *sequences in my C code.

For something like this it is better to use the .Call interface than
to use the .C interface.  See the description in "Writing R
Extensions".  If that documentation is insufficient then I can send
you copies of the slides from our short course on "Advanced
Programming in R" from DSC-2003.




More information about the R-help mailing list