Skip to content
Prev 68333 / 398513 Next

ugly loop

On Fri, 2005-04-22 at 09:31 -0400, Bill Simpson wrote:
That's what I get for not comparing your results against my own.  I just
noted that you are going by row and not by column. So, using the same
data above:
+   for(j in 1:ncol(ver))
+     {
+     count<-count+1
+     x[count]<-pt$x[ver[i,j]]
+     y[count]<-pt$y[ver[i,j]]
+     z[count]<-pt$z[ver[i,j]]
+     }
[1] 10  4 13  2  3 12  6  8  7  9 16 15  1 11 14  5
[1]  5 12  7 16  9  3 15  8 13  2 11 10 14  1  4  6
[1] 12  2 14 11 16  6 15 13  9  3  1  4  7  5 10  8


Thus, I just need to use t(ver) instead of ver:
[1] 10  4 13  2  3 12  6  8  7  9 16 15  1 11 14  5
[1]  5 12  7 16  9  3 15  8 13  2 11 10 14  1  4  6
[1] 12  2 14 11 16  6 15 13  9  3  1  4  7  5 10  8

That should do it?

HTH,

Marc
<Off to make another pot of coffee....>