Saptarshi Guha
2013-May-20 16:56 UTC
[Rd] Accessing i'th element of a vector without using a macro
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
Gabriel Becker
2013-May-20 17:03 UTC
[Rd] Accessing i'th element of a vector without using a macro
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@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@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >-- Gabriel Becker Graduate Student Statistics Department University of California, Davis [[alternative HTML version deleted]]