Re: [R] Nested functions

From: John Wiedenhoeft <wiedenhoeft_at_gmx.net>
Date: Tue 18 Jul 2006 - 18:25:49 EST

Am Montag, den 17.07.2006, 19:42 -0400 schrieb jim holtman:
> You were down at least 5300 levels in subroutine calls. Here is the
> first couple of lines from 'traceback()':
>
> 5363: vavb(a, b, n, v, x)

...
> 5316: vavb(a, b, n, v, x)

> The other thing is that there is no 'x' defined in the function;
>
> antiphonar <- function(v)
> {
> a <- 1;
> b <- 2;
> n <- length(v);
> alessn(a, b, n, v, x);
> }
>
> and this is the initial call to the rest of the functions.

Ooops... normally I don't program THAT bad ... ;-)

> What is the problem you are trying to solve?

I'm analyzing a 16th century music manuscript. There is no rhythm notated there, but I can to a certain degree restore it by finding self-similarities in the melodic structure. The vector v is an ordered list of intervals. I could find them by hand, but this takes time and things are easily missed. Besides, for a 200 pages manuscript coding the vectors takes long, but finding similarities by hand takes endless... :-(

The problem remains. I'm not sure I did completely understand the way R works. My plan was to jump out of one function to another. I think what R does is assigning a function's return value to an internal variable and tries to evaluate another function WITHIN a calling function, which of course leads to deep nesting and a bunch of internal variables. Too bad there is no "goto" statement in R... Isn't there a way to make R "forget" that it just evaluated e.g. alessn the moment it calles vavb? That algorithm itself isn't that hard. In the end it's just a decision diagram of the form "if THIS, goto THIS knot, otherwise goto THAT knot". Each knot has only one arrow pointing away from it, but sometimes more than one pointing toward it. I could send the diagram as an attachement, if you like.

Cheers,
John

P.S.: Please keep messages on the list. Thank you!



R-help@stat.math.ethz.ch 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. Received on Tue Jul 18 19:39:43 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 18 Jul 2006 - 20:17:26 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.