[R] create an object list in a loop
Jake Bowers
jbowers at csm.berkeley.edu
Mon Oct 28 15:20:25 CET 2002
Hi.
How about:
n<-10
aval<-list()
for(i in 1:n){
aval[[i]]<-matrix(....)
}
Then you could access the first matrix as aval[[1]]
Good luck.
Jake
------
Jake Bowers
Dept of Political Science
University of Michigan
On Mon, 28 Oct 2002 AlessandroSemeria at cramont.it wrote:
> Hi! Probably I perform this question because I did'nt still understand the
> R-philosophy.
> I have to build many matrix, with different dimensions, and I would to
> assign them a
> same 'prefix' name, i.e. "aval", but, obviuosly different suffix, something
> like:
> for (i in 1:n) {
> aval%i% <- matrix(scan(data....),nrow=nr[i],ncol=nc[i]
> ...
> }
> where "%i%" is a symbol to indicate different label for different index i.
> Ther'is some trick to "paste" a label(i) and to build the object aval%i%
> or some other way
> to perform my task?
> Thanks in advance for your help!
> --------------------------
> Sincerely yours.
> Dr. Alessandro Semeria
> Models and Simulation Lab of
> The Environment Research Center - Montecatini (Edison Group),
> Via Ciro Menotti 48,
> 48023 Marina di Ravenna (RA), Italy
> Tel. +39 544 536811
> Fax. +39 544 538663
> E-mail: asemeria at cramont.it
>
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list