Skip to content
Back to formatted view

Raw Message

Message-ID: <200305051920.34627.chrysopa@insecta.ufv.br>
Date: 2003-05-05T22:22:43Z
From: Ronaldo Reis Jr.
Subject: Help to make a for for index

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