[R] Error: C stack usage is too close to the limit
Maarten Blaauw
maarten.blaauw at geo.uu.se
Sun Jan 27 00:55:14 CET 2008
Sorry, indeed I forgot to put some of the factors in the code. Here it
is again, now updated:
calcurve <- cbind(1:2e4, 1:2e4, rep(100, length=2e4));
caldist <- function(cage, error, sdev=2, times=5, By=1)
{
calcurve <- calcurve[which((calcurve[,2]+calcurve[,3]) >=
cage-(times*error)),];
calcurve <- calcurve[which((calcurve[,2]-calcurve[,3]) <=
cage+(times*error)),];
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(2450,50);
Strangely enough the stacking error message seems not to happen every
time. It also has happened on the WinXP partition of the same Toshiba
laptop. So it is not as reproducible as I first hoped/feared.
--
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
More information about the R-help
mailing list