Skip to content
Prev 206610 / 398503 Next

Odp: For loops in R

Hi

Definitely not

from first I get
Error in runif(popsize, min = 1, max = top) : object 'popsize' not found
and from second
+   for (j in 1:maxvar) {
+    gBest<-sample(top,size=1) 
+    velocity[i,j]<<-.4* velocity[i,j] + 1 * runif(1) * (pbestsVar[i,j] -
+ popVar[i,j]) + 1 * runif(1) * (archiveVar[gBest,j] - popVar[i,j])
+    #velocity[i,j]<-.4* velocity[i,j] + 1 * .3722 * (pbestsVar[i,j] -
+ popVar[i,j]) + 1 * .3722 * (archiveVar[3,j] - popVar[i,j])
Error: unexpected ')' in:
"   #velocity[i,j]<-.4* velocity[i,j] + 1 * .3722 * (pbestsVar[i,j] -
popVar[i,j])"
If you by chance have all data necessary for those codes not to give those 
stupid errors you could transfer their output to different objects and 
check those objects if they are equivalent.

?all.equal

Regards
Petr


r-help-bounces at r-project.org napsal dne 17.01.2010 08:17:16:
(pbestsVar[i,j] -
-
http://n4.nabble.com/For-loops-in-R-tp1015933p1015933.html
http://www.R-project.org/posting-guide.html