From dusa.adrian at gmail.com  Tue Nov 26 17:12:08 2013
From: dusa.adrian at gmail.com (=?UTF-8?B?QWRyaWFuIER1xZ9h?=)
Date: Tue, 26 Nov 2013 18:12:08 +0200
Subject: [Rd] dynamic lists at C level
Message-ID: <CAJ=0CtCn-GKHZ6VhNxuVbHF0oSpVrSYN_7Yy6swOHi4x1-25Hw@mail.gmail.com>

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



[Rd] dynamic lists at C level
=?UTF-8?B?QWRyaWFuIER1xZ9h?=