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

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Jun 20 19:10:59 CEST 2001


Duncan Murdoch <murdoch at stats.uwo.ca> writes:

> I don't know why one version works and the other doesn't, but I've
> noticed problems in the past when using "data" as a variable name, and
> in fact even the first version fails for me when I type it exactly as
> you did.
> 
> I suspect the strange behaviour you saw is related to the fact that
> data is a matrix rather than a data.frame, and indeed everything is
> fine if I change your code to

I got it now: The problem is that eval accept an integer as its envir
argument (as in sys.call()) so lm and friends do too. If you pass a
numeric object, like a matrix, the first element is extracted and
coerced to integer. That'll explain why the behaviour changes when a
column is multiplied by 149...

The reason the example ever worked was that x,y,z from the global env.
got picked up.
-- 
   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