[R] Error in eval(expr, envir, enclos) : object 'N' not found

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Dec 6 19:49:46 CET 2009


hansoffate wrote:
> Oh yes, that's true, but I don't understand why the same exact model works
> fine the first time I run LSODA, then running the model again with different
> PARMS causes it to error  with this error.  I've been trying to debug or
> find other relevant posts with this same error, but so far I have had no
> lucky.  
> 
> Any help would be appreciated.
> -Hans

Just print out state and state2, and you'll see that you are being done 
in by naming rules:

 > state2
          T.T          N.N          C.C          M.M
1.100422e+03 2.027655e+05 1.473149e+10 0.000000e+00
 > state
    T    N    C    M
1000   10 1000    0
 > pars2$Tini
        T
1100.422
 > pars$Tini
[1] 1000

I.e., the problem is that using the naming forms of c() with vectors 
that already have names tries to combine the names into new names.

 > c(a=c(a=2))
a.a
   2

In your case, it looks like it works just to avoid the extra layer of 
naming:
 >   state2   <- c(pars2$Tini, pars2$Nini, pars2$Cini, pars2$Mini)
 >   out2     <- lsoda(state2, tout, model2, pars2)
 > out2
        time        T        N           C M
   [1,]  0.0 1100.422 202765.5 14731494538 0
   [2,]  0.1 1100.888 203427.9 14788782468 0
   [3,]  0.2 1101.355 204088.5 14846001846 0
   [4,]  0.3 1101.823 204747.4 14903152673 0
   [5,]  0.4 1102.290 205404.6 14960234948 0
....


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