[R] Error using lm(z~x+y,data)
    Peter Dalgaard BSA 
    p.dalgaard at biostat.ku.dk
       
    Wed Jun 20 16:29:27 CEST 2001
    
    
  
Peter Dalgaard BSA <p.dalgaard at biostat.ku.dk> writes:
> tomsv193 at student.liu.se writes:
> 
> > Hi!
> > 
> > I am fitting a plane to a surface:
> > 
> > This works excellent:
> > ---------------------------------
> > x<-dataframe[,1]
> > y<-dataframe[,2]
> > z<-dataframe[,3]
> > data<-cbind(x,y,z)
> > 
> > # Fit plane to surface
> > result<-lm(z~x+y,data)
> > ---------------------------------
> > 
> > But I need to rescale the x,y parameters. So:
> > -----------------------------
> > x<-dataframe[,1]*149
> > y<-dataframe[,2]*149
> > z<-dataframe[,3]
> > data<-cbind(x,y,z)
> > 
> > # Fit plane to surface
> > result<-lm(z~x+y,data)
> > ----------------------------------
> > 
> > And surprisingly this does not work. Error message is:
> > 
> > Error in eval(attr(formula, "variables"), data, env) : 
> >         sys.frame: not that many enclosing functions
> > 
> > Why does this happen?
> 
> 
> I can confirm this, but not understand it. Certainly looks like a bug.
Ah, got it! The data= argument needs to be a dataframe and you have a
matrix. Still looks weird, though.
-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
    
    
More information about the R-help
mailing list