Output and save results of a nested loop in R

Because when you call my_vector[j]<-(E[j]), j only takes values between 1 and length(w), so for each iteration of the loop i you rewrite everything (each time you change of value for i then j restarts to 1).

Replace by:

my_vector[j + length(w)*(i-1)]<-(E[j])

Also, I think that you should remove the last line with


As it is outside of the loop on j (or at least I don’t understand why it is here)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top