Skip to content

Problem with Loop and overwritten results

3 messages · unbekannt, David Winsemius

#
Dear all,

 I am a newbie to R and practising at the moment.

 Here is my problem:

 I have a programme with 2 loops involved.
 The inner loop get me matrices as output and safes all values for me.

 Now once I wrote a 2nd loop around the other loop in order to
 repeat the inner loop a couple of times, the results are overwritten and
 i found no way how to actually put the output results in a vector.

 I can receive single results only, like this

 [1] number
 [1] number2
....

but it want it rather like this

[1] number number2 number3 ...

any advice?

Thanks
unbekannter weise
#
Dear unbekannt;

The construction that would append a number to a numeric vector would  
be:

vec <- c(vec , number)

You can create an empty vector with vec <- c() or vec <- NULL
#
thank you so much!
this solved my problem
unbekannt wrote:
:clap: