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

From: Michael <wuolong_at_gmail.com>
Date: Thu 21 Dec 2006 - 17:08:15 GMT

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?



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Fri Dec 22 17:54:46 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 22 Dec 2006 - 17:31:04 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.