[R] macro variable in R?

Benilton Carvalho beniltoncarvalho at gmail.com
Thu Apr 22 18:23:36 CEST 2010


maybe

for (i in 1:10) assign(paste("matrix", i, sep="_"), matrix(nrow=i, ncol=i))

suffices?

On Thu, Apr 22, 2010 at 5:08 PM, karena <dr.jzhou at gmail.com> 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
>
> --
> View this message in context: http://r.789695.n4.nabble.com/macro-variable-in-R-tp2020772p2020772.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list