[R] "infinite recursion" in do.call when lme4 loaded only

Peter Dalgaard p.dalgaard at biostat.ku.dk
Thu Jan 12 18:26:55 CET 2006


"Dieter Menne" <dieter.menne at menne-biomed.de> writes:

> A larg program which worked with lme4/R about a year ago failed when I
> re-run it today. I reproduced the problem with the program below.
> 
> -- When lme4 is not loaded, the program runs ok and fast enough
> -- When lme4 is loaded (but never used), the do.call fails
>    with infinite recursion after 60 seconds. Memory used increases
>    beyond bonds in task manager.
> -- I tested a few S3 based packages (MASS, nlme) and did not get
>    similar problems
> 
> Current workaround: do lme4-processing in a separate program.

Looks like it conks out when the number of frames to rbind is bigger
than about 110. 

Current releases have
> options("expressions")
$expressions
[1] 1000

It was 5000 for a while, but we found that it could overflow the C
stack on some systems. Since your example has 720 lines, I can't quite
rule out that that the problem was really there all the time.

However, it surely has to do with methods dispatch:

> system.time(do.call("rbind.data.frame",caScore))
[1] 0.99 0.00 0.99 0.00 0.00

which provides you with another workaround.

 
> 
> ------
> #library(lme4) # uncomment this to see the problem
> np <- 12
> nq <- 20
> nph <- 3
> nrep <- 30
> grd <- expand.grid(Pat=as.factor(1:np),
>             Q=as.factor(1:nq),
>             Phase=as.factor(1:nph))
> df <- with (grd,
>   data.frame(Pat=Pat,Q=Q,Phase=Phase,Resp = rnorm(np*nq*nph*nrep)))
> 
> score <- function(x) {
>  data.frame(Pat=x$Pat[1],Phase=x$Phase[1],Q=x$Q[1],score = mean(x$Resp))
> }
> 
> # about 20 sec
> caScore <- by(df,list(Pat=df$Pat,Phase=df$Phase,Q=df$Q),FUN = score )
> 
> ca1 = do.call("rbind",caScore)
> # Without lme4: 3 seconds
> # With lme4: After 60 sec:
> #Error: evaluation nested too deeply: infinite recursion /
> #options(expressions=)?
> 
> 
> -----------------------
> 
> platform i386-pc-mingw32
> arch     i386
> os       mingw32
> system   i386, mingw32
> status
> major    2
> minor    2.1
> year     2005
> month    12
> day      20
> svn rev  36812
> language R
> 
> ______________________________________________
> R-help at 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
> 

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907




More information about the R-help mailing list