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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear Allesandro, At 12:38 PM 10/28/2002 +0100, 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!You can use paste() within assign() to compose the variable names: assign(paste("aval", i, sep=""), matrix(scan(data....),nrow=nr[i],ncol=nc[i]) (I'm not sure what it is you're assigning to each of these variables, but I assume that it makes sense.) I hope that this helps, John ----------------------------------------------------- John Fox Department of Sociology McMaster University Hamilton, Ontario, Canada L8S 4M4 email: jfox at mcmaster.ca phone: 905-525-9140x23604 web: www.socsci.mcmaster.ca/jfox ----------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Thanks at all for yours precious help. My mistake had origin from the bad use of '<- ' . I thought (from R-help pages) ' <- ' and 'assign' statements as synonyms. Evidently I'm not feel with "R-mind", in fact the suggestion done by Peter Dalgaard : aval <- lapply(1:n, function(i) matrix(.....)) is good, it work, but reading R-help ("lapply(X, FUN, ...)....") is not so clear for me how this work. Bye A.S. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._