[R] From a list to a double-list/matrix

From: Alaios <alaios_at_yahoo.com>
Date: Mon, 28 Mar 2011 08:11:36 -0700 (PDT)


Dear all ,
I would like to extend a list structure to a structure that can hold much more date. Please find a small example of my code and my questions regarding it:

lst <- list()

for (k in c(1:mmax)){ # 1 ..max as the f.fxy gets as input order-1.   for (l in c(1:nmax)){

	sr[findCoord(c(i,j),sr)[1],findCoord(c(i,j),sr)[2]]<-fxy(c(i,j))
      }

    }
    lst[[listcounter]] <-sr # Store the value inside lst     listcounter<-listcounter+1
  }
}

In the code above I was calculating the values of a matrix sr(200*200 matrix) and then I was storing the whole .matrix inside the list called lst (lst[[listcounter]]<-sr).

This was used for one scenario. I would like to run the same but for 100 different scenarios (randomly created). Thus I want to extend lst to a double-list or a matrix that for every different out of the 100 scenarios stores everything. The ideal would be to have
lst[[listcounter]][[scenario_index]]<-sr where scenario_index is the index for the current scenario (ranges from 1 to 100).

Could you please explain me how I can do that in R?

Regards
Alex



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 Mon 28 Mar 2011 - 15:14:37 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 Mon 28 Mar 2011 - 15:40: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