[Rd] dynamic lists at C level

Adrian Duşa dusa.adrian at gmail.com
Tue Nov 26 17:12:08 CET 2013


Dear R-devel,

I am trying to do something similar to dynamic length lists in R, but
at C level.

In R, that would be rather trivial:
- determine the length of the list
- create the list object
- store the values for each component
- access value components by using "[["

At C level, for a single component where I need to store a vector of
length 5, I do:

int *p_result;
SEXP my_list = PROTECT(allocVector(VECSXP, 1));
SEXP result = SET_VECTOR_ELT(my_list, 0, allocVector(INTSXP, 5));
p_result = INTEGER(result);


The number "1" (the length of "my_list") is dynamic, however.
Is there a web reference where I could do some further reading on this topic?

Thank you,
Adrian

-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd.
050025 Bucharest sector 5
Romania
Tel.:+40 21 3126618 \
        +40 21 3120210 / int.101
Fax: +40 21 3158391



More information about the R-devel mailing list