[R] Problem with length of array while calling C from R

Sven Knüppel sven.knueppel at reilich.net
Tue Apr 24 13:53:09 CEST 2007


Hello,

my problem is that I don't know how long must be an array of double while calling C from R.

R-Code:
> array <- c(1,1,1)
> save <- .C ( "Ctest" , a = array )

C-Code:
void Ctest ( double *array )
{ ...
  array = (double*) realloc ( array , new_number * sizeof(double) ) ;
  ...
}

The length of "array" will be compute in C.

At the end save$a has a length of 3 and not the length of the allocated array in C.

What can I do?

Thank you in advance.

Sven Knüppel



More information about the R-help mailing list