I'm interfacing to C code that uses 1-based indexing on arrays -- it
ignores the zeroth element.  Thus, input vectors from R must be moved up
one, and output arrays must be moved down one.

What is the best way to deal with this using R internal code?

My current approach is:

For an input R vector of length n, allocate a new vector(v) of length n+1
and copy input into v[1] to v[1+n].  Call with new vector.

For an output array(a) of length n, allocate a new vector of length n-1
and copy a[1] to a[n] into v[0] to v[n-1].

If this is the best approach, is there an idiom for copying vectors?

-Lopaka

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to