[R] From a list to a double-list/matrix
Alaios
alaios at yahoo.com
Mon Mar 28 17:11:36 CEST 2011
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
More information about the R-help
mailing list