[R] Error: C stack usage is too close to the limit

jim holtman jholtman at gmail.com
Sat Jan 26 23:51:42 CET 2008


Your function has 4 parameters and you are only calling with two.  The
first statement:

caldist <- function(cage=Cage, error=Error, sdev=Sdev, times=Times, By=By)
 {
  theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);

use "By" which is not defined.

On Jan 26, 2008 4:29 PM, Maarten Blaauw <maarten.blaauw at geo.uu.se> wrote:
> Lately R has been behaving strange on my Linux (Ubuntu 7.10) machine,
> with occasional segfaults. Today something else and reproducible
> happened:
>
> If I type the code below (meant for calibrating data), I get the error
> message that "the C stack usage is too close to the limit".
>
> calcurve <- cbind(1:2e4, 1:2e4, 1:2e3); #dummy curve, real one is more complex
>
> caldist <- function(cage=Cage, error=Error, sdev=Sdev, times=Times, By=By)
>  {
>   theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);
>
>   interpolate <- function(th, col)
>    {
>     if(th==calcurve[1,1]) {calcurve[1,col]}else
>     if(th==calcurve[nrow(calcurve),1]) {calcurve[nrow(calcurve),col]}else
>      {
>       k <- min(which(calcurve[,1] > th));
>       slope <-
> (calcurve[k-1,col]-calcurve[k,col])/(calcurve[k-1,1]-calcurve[k,1]);
>       calcurve[k-1,col] + slope*(th-calcurve[k-1,1]);
>      }
>    }
>
>   mu <- c();
>   cerror <- c();
>   for(i in 1:length(theta))
>    {
>     mu[i] <- interpolate(theta[i],2);
>     cerror[i] <- interpolate(theta[i],3);
>    }
>
>   caldist <- dnorm(mu, cage, (error^2+cerror^2)^.5);
>   cbind(theta, caldist/sum(caldist));
>  }
>
> caldist(1e3,1e2);
>
> Unfortunately I am no huge computer wizard. Has anyone got any idea
> why this happens? Is it reproducible on other machines? How can I
> solve this problem?
>
> My R:
> R version 2.6.1 (2007-11-26)
> i486-pc-linux-gnu
>
> locale:
> LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] rcompgen_0.1-17
>
> Cstack_info()
>       size    current  direction eval_depth
>    8388608       2404          1          2
>
> Many thanks,
>
> Maarten Blaauw
>
> --
> Dr. Maarten Blaauw
> School of Geography, Archaeology & Palaeoecology
> Queen's University Belfast, U.K.
> On leave from Department of Earth Sciences
> Uppsala University, Sweden
> maarten.blaauw at geo.uu.se
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list