# [R] lists within lists

Darcy Webber darcy.webber at gmail.com
Tue Apr 5 03:15:07 CEST 2011

```Hello R users,

I am dealing with some resonably big data sets that I have split up
into lists based on various factors. In the code below, I have got my
code producing 100 values between point1x and point1y for the first
matrix in my list.

for (k in 1:length(point1x[][, 1])) {
linex[[k]] = seq(point1x[][, 1][k], point2x[][, 1][k], length = 100)}

This works properly when I specify point1x[] and point2x[], but
I need to repeat this process for point1x[]... point1x[[j]] and
append it within another list. Perhaps something along the lines of
this,

for (j in 1:length(something)) {
for (k in 1:length(point1x[[j]][, 1])) {
linex[[j]][[k]] = seq(point1x[[j]][, 1][k], point2x[[j]][, 1][k],
length = 100)}}

But, R wont let me do this, so, my question is, how can I produce
lists within lists in R using a similar code to above? I could do this
manually by changing the values of n and then setting up the list
using

biglist[] = linex #for n=1
biglist[] = linex #for n=2 etc

I can then call to lists within the list using biglist[][] etc,
but I need to automate all of this. Am I missing something basic with
respect to list structures?

Thanks again,
Darcy.

```