[R] Problem with loop, matrix and data frame

2013-11-26 Thread ANNA SIMEONIDOU
Hi all, I'm sorry, maybe the solution in my problem is easy, but i am still new to R, and any help here is appreciated! I want to create a data frame, or a matrix in which the output of each loop will be stored. Here is the program n-c(10,8,7,5) n_goal-c(8,9,9,4) w-c(0.1,0.1,0.1,0.1)

Re: [R] Problem with loop, matrix and data frame

2013-11-26 Thread jim holtman
You reused 'i' in the inner 'for' loop. This looks like it give the correct answer: n-c(10,8,7,5) n_goal-c(8,9,9,4) w-c(0.1,0.1,0.1,0.1) matrix-mat.or.vec(6,4) FI-function(n_t) { + (((n_goal[1]-n[1]+W[1]-f[1]+n_t[1])^2)+((n_goal[2]-n[2]+W[2]-f[2]+n_t[2]-n_t[1])^2)+ +