From wuolong at gmail.com  Thu Dec 21 18:08:15 2006
From: wuolong at gmail.com (Michael)
Date: Thu, 21 Dec 2006 11:08:15 -0600
Subject: [Rd] variable scope in update(): bug or feature?
Message-ID: <c2hcvp2n40.fsf@bass.biostat.umn.edu>


I stumbled upon this when using update() (specifically update.lm()).  If
in the original call to lm(), say

a <- lm (y ~ x + z, data = mydata)

where y and z are in data frame mydata but x is in the global environment.

Then if later I run,

a0 <- update (a, ~ . - z)

a0$model will contain values of x in the global environment which may well
be different, even different length from mydata$y.  Somehow, update() pads
a0$model to have the same number of rows as the length of x.

I would think that it would desirable to use x as in a$model rather than the
global one.  

Is this a bug or a deliberate feature?

Thanks,

Michael



[Rd] variable scope in update(): bug or feature?
Michael