[R] array of variable length vectors

Uwe Ligges ligges at statistik.uni-dortmund.de
Mon Feb 2 12:48:42 CET 2004


Giampiero Salvi wrote:

> Hi,
> I'd like to store N vectors of different lengths, and to be able to
> access them with an index, and eventually free the memory for one
> of them without modifying the indexes to the others.
> 
> In C this would be a vector of N pointers that point to memory cells
> independently allocated.
> 
> For example
> 
> int *pv[3];
> 
> pv[0] = (int *) malloc(13 * sizeof(int));
> pv[1] = (int *) malloc(7 * sizeof(int));
> pv[2] = (int *) malloc(110 * sizeof(int));
> 
> free(pv[1])
> ...
> 
> What is the best data type (or class) in R to do such a thing?

See ?list

Uwe Ligges




More information about the R-help mailing list