update 'groupedData' and 'lme' objects

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

update 'groupedData' and 'lme' objects

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

[hidden email] mailing list
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html