[Rd] Accessing i'th element of a vector without using a macro

Saptarshi Guha saptarshi.guha at gmail.com
Mon May 20 19:35:35 CEST 2013


Exactly, that is what i use. I intend to do the operation using an FFI
library(i't s just a proof of concept, and there well might be
performance hits)
If such a function doesn't exist in libR.so, then i can write one.

Regards
Saptarshi


On Mon, May 20, 2013 at 10:03 AM, Gabriel Becker <gmbecker at ucdavis.edu> wrote:
> Saptarshi,
>
> When I need to repeatedly access data from a an R vector in C I typically
> just create a pointer to the data and just use that.
>
> double *xdat = REAL(x);
> xdat[i]; //repeat as necessary
>
> This is also displayed in 5.9.4 of the R extensions manual.
>
> Is there a reason this wouldn't work for your usecase? What exactly is it
> that you want to do?
>
> ~G
>
>
>
>
> On Mon, May 20, 2013 at 9:56 AM, Saptarshi Guha <saptarshi.guha at gmail.com>
> wrote:
>>
>> Hello,
>>
>> I have a double vector, x. I can access the i'th element as
>>
>> REAL(x)[i]
>>
>> Is there a function for this? I know i can write my own, but was
>> seeing if one already exists. I did check Rinternals.h but didn't see
>> one.
>>
>> Cheers
>> Saptarshi
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>
>
>
> --
> Gabriel Becker
> Graduate Student
> Statistics Department
> University of California, Davis



More information about the R-devel mailing list