[R] Help to make a for for index
Ronaldo Reis Jr.
chrysopa at insecta.ufv.br
Tue May 6 00:22:43 CEST 2003
Hi,
I try to make a vector in a for for loop, but it dont work.
Look:
> a <- 0;for(i in c(1:2)) { for(j in c(1:2)) { a <- i+j; print(a)}}
[1] 2
[1] 3
[1] 3
[1] 4
I try to make this a vector, like this:
[1] 2 3 3 4
> a <- 0;for(i in c(1:2)) { for(j in c(1:2)) { a[j] <- i+j}}; print(a)
[1] 3 4
> a <- 0;for(i in c(1:2)) { for(j in c(1:2)) { a[i] <- i+j}}; print(a)
[1] 3 4
In this way the vector have only the two last loop.
I try another way but it dont work.
How make a correct index for this loop inside loop?
Thanks
Ronaldo
--
As coisas por aqui não andam, arrastam-se lentamente em direção
a lugar nenhum.
Eu hoje acordei assim, otimista...
--
| // | \\ [*****************************][*******************]
|| ( õ õ ) [Ronaldo Reis Júnior ][PentiumIII-600 ]
| V [UFV/DBA-Entomologia ][HD: 30 + 10 Gb ]
|| / \ [36571-000 Viçosa - MG ][RAM: 128 Mb ]
| /(.''`.)\ [Fone: 31-3899-2532 ][Video: SiS620-8Mb ]
||/(: :' :)\ [chrysopa at insecta.ufv.br ][Modem: Pctel-onboar]
|/ (`. `'` ) \[ICQ#: 5692561 ][Kernel: 2.4.18 ]
|| ( `- ) [*****************************][*******************]
||| _/ \_Powered by GNU/Debian W/Sarge D+ || Lxuser#: 205366
More information about the R-help
mailing list