[R] macro variable in R?
Mario Valle
mvalle at cscs.ch
Thu Apr 22 18:20:10 CEST 2010
Why don't use a list?
m <- list()
for(i in 1:10) {
m[[i]] <- matrix(NA, i, i)
}
then access them as m[[7]][1,6]
Ciao!
mario
On 22-Apr-10 18:08, karena wrote:
>
> I need to create 10 matrices. say matrix 1-10.
>
> matrix_1 is 1 by 1
> matrix_2 is 2 by 2
> matrix_3 is 3 by 3
> .
> .
> .
> matrix_10 is 10 by 10
>
> I am just wondering if there are some functions in R that are similar to the
> macro variables in SAS. so I can create these 10 matrices by doing:
> for (i in 1: 10) {
> matrix_$i<- matrix(nrow=i, ncol=i)
> }
>
> rather thank creating these matrices one by one manually.
>
> Anyone have any suggestions?
>
> thanks,
>
> karena
>
--
Ing. Mario Valle
Data Analysis and Visualization Group |
http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the R-help
mailing list