Hi all, I am getting evaluation nested too deeply: infinite recursion / options(expressions=)? in my code. Trying to investigate it with traceback() returns a very long list, index go even more then 495, so I can not read everything because it is not possible to scroll more. Is it possible to redirect output of traceback to a file? This is the only solution I can think, is there another? Any comments are welcome. Thanks. func <- Vectorize(function(x, a, sad, trunc=0, ...) { result <- function(x) { f1 <- function(n) { dcom <- paste("d", deparse(substitute(sad)), sep="") dots <- c(as.name("n"), list(...)) f <- do.call(dcom, dots) g <- dpois(x,a*n) f * g } integrate(f1, 0, Inf)$value } return(result(x) / (1 - result(trunc))) }, "x") func(1, 0.1, exp)
On Aug 31, 2011, at 9:58 AM, . . wrote:> Hi all, > > I am getting evaluation nested too deeply: infinite recursion / > options(expressions=)? in my code.Splitting this into another thread seems unnecessary.> > Trying to investigate it with traceback() returns a very long list, > index go even more then 495, so I can not read everything because it > is not possible to scroll more. > > Is it possible to redirect output of traceback to a file??sink ?capture.output (From your offline communication I got the idea you were running R 2.8.1. If that is true, then you should make that fact more apparent to your audience.)> This is the > only solution I can think, is there another? > > Any comments are welcome. > > Thanks. > > func <- Vectorize(function(x, a, sad, trunc=0, ...) { > result <- function(x) { > f1 <- function(n) { > dcom <- paste("d", deparse(substitute(sad)), sep="") > dots <- c(as.name("n"), list(...)) > f <- do.call(dcom, dots) > g <- dpois(x,a*n) > f * g > } > integrate(f1, 0, Inf)$value > } > return(result(x) / (1 - result(trunc))) > }, "x") > > func(1, 0.1, exp) > > ______________________________________________ > R-help at r-project.org 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.David Winsemius, MD West Hartford, CT
On 31/08/2011 9:58 AM, . . wrote:> Hi all, > > I am getting evaluation nested too deeply: infinite recursion / > options(expressions=)? in my code. > > Trying to investigate it with traceback() returns a very long list, > index go even more then 495, so I can not read everything because it > is not possible to scroll more. > > Is it possible to redirect output of traceback to a file? This is the > only solution I can think, is there another?You can also look at the .Traceback variable. The traceback() function just prints it in a nice way. I believe the top of stack is at the end of .Traceback, so something like depth <- length(.Traceback) .Traceback[depth:(depth-10)] should print the top ten entries on the stack, topmost first. Duncan> Any comments are welcome. > > Thanks. > > func<- Vectorize(function(x, a, sad, trunc=0, ...) { > result<- function(x) { > f1<- function(n) { > dcom<- paste("d", deparse(substitute(sad)), sep="") > dots<- c(as.name("n"), list(...)) > f<- do.call(dcom, dots) > g<- dpois(x,a*n) > f * g > } > integrate(f1, 0, Inf)$value > } > return(result(x) / (1 - result(trunc))) > }, "x") > > func(1, 0.1, exp) > > ______________________________________________ > R-help at r-project.org 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.