Hi Mary, Some things are clear from your code fragment: - S_X is a variable external to your function, and is possibly a variable accessible to robustm. - Unless calling robustm changes S_X or abs(b1[i,i]-b)[i,i])<=0.001 is always true for all S_X and all i, your repeat statement, and so your function, will never terminate. Otherwise, your code fragment is opaque, and unless you tell me something you have not stated in your email, I cannot help you. I'm sorry.
Best, Mario On Fri, Jan 4, 2013 at 6:13 AM, mary <mary.d...@libero.it> wrote: > Hi, > I'm Marianna > I'm trying to apply the command "repeat" to my matrix but the repeat > process > doesn't work as I would. > > In particular I would like to apply the function robustm () _that I have > created_ to my two matrices, if the difference between the two matrices is > less than 0.001, R give me back the last matrix. > The code thus created allows me to repeat the process only on the first two > matrices: > > function(x) { > for(i in 1:10) > repeat { > b<-robustm(S_X) > b2<-robustm(b) > if(abs(b2[i,i]-b[i,i])<=0.001) > break > } > print(b2)} > > in particular S_X is my matrix number1 (already defined, dim 10*10), b2 is > my matrix n.2, if the difference isn't less than my value, I would like > reiterate the process using b2 instead S_X and so on... > > (actually serves to me that if the difference is not less than 0.001 the > process starts again taking the last array that has identified as output > (in > this case b2) and the remarket in the process creating b3, b4, etc. up to > find the minimum difference between the two matrices and returns me the > last.) > > Sorry if I am not so clear, thanks > Mary > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Iterative-loop-using-repeat-tp4654625.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Mario Bourgoin, Ph.D. Department of Mathematics Brandeis University Waltham, MA [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.