From maechler at stat.math.ethz.ch  Fri Dec 22 09:17:21 2006
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 22 Dec 2006 09:17:21 +0100
Subject: [Rd] variable scope in update(): bug or feature?
In-Reply-To: <c2hcvp2n40.fsf@bass.biostat.umn.edu>
References: <c2hcvp2n40.fsf@bass.biostat.umn.edu>
Message-ID: <17803.38033.644533.557922@stat.math.ethz.ch>

Hi Michael,
can you please

- use a simple reproducible example -- 
  just for the convenience of your readers

- use R-help.  This is really a question about R.



>>>>> "Michael" == Michael  <wuolong at gmail.com>
>>>>>     on Thu, 21 Dec 2006 11:08:15 -0600 writes:

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

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

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

    Michael> Then if later I run,

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

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

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

    Michael> Is this a bug or a deliberate feature?

    Michael> Thanks,

    Michael> Michael

    Michael> ______________________________________________
    Michael> R-devel at r-project.org mailing list
    Michael> https://stat.ethz.ch/mailman/listinfo/r-devel



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