Loop.R

From Organic Design wiki
Revision as of 22:43, 12 December 2005 by Sven (talk | contribs) (Naming the loop)
  1. ==============================================================================
  2. Loop evaluation e.g. 6 parts, 4 comparisons
  3. this function is construting an array e.g. 1,2,3,4,5,6,1,2,3
  4. and then subsetting sequential arrays of length four from it
  5. e.g. 1,2,3,4 2,3,4,5 3,4,5,6 etc
  6. ==============================================================================

start <- 1 loop <- 6 comp <- 4 loopId <- 0:(loop+comp-1) %% loop +1

loopName <- c(0,14,25, 35,60,87,132,146)

for(i in seq(loop)){

 print(loopName[loops[seq(from=i, length=comp)]])

}

  1. Returns;
  2. 0 14 25 35
  3. 14 25 35 60
  4. 25 35 60 87
  5. 35 60 87 0
  6. 60 87 0 14
  7. 87 0 14 25