  Dear R users, I have the following code:
  ----------------------------------------
  require(nlme)
  myfunc <- function(data, n, m, maxIter = 3){
  working <- groupedData(formula = y~x|id, data=data)
val <- NULL
  r <- 0
 while(r < maxIter){
  new.data <- data.frame(x=rnorm(n),y=rnorm(n),id=rep(1:n,each=m))
  working <- update(working, data = new.data)
  # val <- some results
  r <- r + 1
 }
val
}
  n <- 10
m <- 2
foo <- data.frame(x=rnorm(n),y=rnorm(n),id=rep(1:n,each=m))
myfunc(foo, n=n, m=m)
  
-----------------------------------------
  
I get this error message:
  > myfunc(foo, n=n, m=m)
Error in inherits(data, "data.frame") : object "new.data" not found
   
  I believe the error is generated within the evaluation of the function 'update'.
The real code I used is more complicated but basically I got a similar error message when using 'update' for an object 'lme', e.g.
   
  function(...){
  fit.lme <- lme(...)
 while(...){
    create newdata
  fit.lme <- update(fit.lme, newdata)
 }
  }
   
  Everything works fine when using an object 'lm'
     
  function(...){

  fit.lm <- lm(...)
 while(...){
    create newdata
  fit.lm <- update(fit.lm, newdata)
 }
  }
  
I might be wrong, but I guess that this problem is related to different evaluation 
  frames, the one invoked by 'myfunc' and the one invoked by 'update' 
  (both for 'lme' and 'groupedData' objects).
   
  Any suggestion to overcome this problem would be greatly appreciated
  Marco Geraci
   
  R version: 2.2.1
  nlme version: 3.1-68.1
  OS: Window XP
   


		
---------------------------------

 Photo Books. You design it and we’ll bind it!
	[[alternative HTML version deleted]]


