Re: [R] Error using lm(z~x+y,data)

About this list Date view Thread view Subject view Author view

From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Thu 21 Jun 2001 - 00:29:27 EST


Message-ID: <x2zob3i5rs.fsf@blueberry.kubism.ku.dk>

Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:

> tomsv193@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@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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view

This archive was generated by hypermail 2b30 : Fri 22 Jun 2001 - 18:58:45 EST