rtist Although I definitely believe this is doable in R (e.g. using lists), last time when I had a similar problem, I turned to C and then called C prg from R. Others might have better solutions.