[R] lists within lists

From: Darcy Webber <darcy.webber_at_gmail.com>
Date: Tue, 05 Apr 2011 13:15:07 +1200

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]][, 1])) { linex[[k]] = seq(point1x[[1]][, 1][k], point2x[[1]][, 1][k], length = 100)}

This works properly when I specify point1x[[1]] and point2x[[1]], but I need to repeat this process for point1x[[2]]... 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[[1]] = linex #for n=1
biglist[[2]] = linex #for n=2 etc

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

Thanks again,

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 05 Apr 2011 - 01:22:46 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 05 Apr 2011 - 01:50:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive