[R] update 'groupedData' and 'lme' objects

From: Marco Geraci <marcodoc75_at_yahoo.com>
Date: Sat 14 Jan 2006 - 07:46:32 EST

  Dear R users, I have the following code:

  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
  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.    

  fit.lme <- lme(...)

    create newdata
  fit.lme <- update(fit.lme, newdata)

  Everything works fine when using an object 'lm'      


  fit.lm <- lm(...)

    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]]

R-help@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 Received on Sat Jan 14 08:05:25 2006

This archive was generated by hypermail 2.1.8 : Sat 14 Jan 2006 - 14:05:40 EST