Skip to content
Prev 353504 / 398502 Next

Recursive looping of a list in R

Hi Evans,

not many people (incl. me) are going to guess the building law for your 
recursive structure from the -- in fact at first sight not so clear -- 
picture, but I have some comments inline below.

  Hth  --  Gerrit
If you use a while-loop without a termination criterion and, e.g., a call 
to break, in its body it would run forever (if the code in its body were 
correct). Start coding with a (finite) for-loop. (Or even better start 
setting j and i "by hand" and let your code be evaluated step by step.)
Here you create in each loop the same starting list (which I guess is not 
what you want/should):
So, as a consequence an error occurs for j >= 2 in the following for-loop, 
because occlist has always only 1 component:
The following two lines of code compensate each other, so seem to be 
superfluous: