Skip to content
Prev 258171 / 398503 Next

Attempting to access an R list from within C code

On 27/04/2011 9:43 AM, Cormac Long wrote:
Generally questions like this are better in the R-devel list, but I'll 
answer this one:

What R calls a list() isn't really a list in the Lisp sense, it's a 
vector.  You access elements in C code by index, e.g.

val = VECTOR_ELT(obj, i);

You set values using code like

SET_VECTOR_ELT(obj, i, newvalue);

Duncan Murdoch