[Rd] update.default: fall back on model.frame in case that the data frame is not in the parent environment

2011-08-02 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
Dear all, Suppose the following code: --8-- mm - function(datf) { lm(y ~ x, data = datf) } mydatf - data.frame(x = rep(1:2, 10), y = rnorm(20, rep(1:2, 10))) l - mm(mydatf) --8-- If I want to update l now without providing the data argument an

Re: [Rd] update.default: fall back on model.frame in case that the data frame is not in the parent environment

2011-08-02 Thread Duncan Murdoch
It looks to me as though your proposal would allow update to remove variables, but would give erroneous results when adding them. For example: mm - function(datf) { lm(y ~ x, data = datf) } mydatf - data.frame(x = rep(1:2, 10), y = rnorm(20, rep(1:2, 10)), z = rnorm(20)) l - mm(mydatf)

Re: [Rd] update.default: fall back on model.frame in case that the data frame is not in the parent environment

2011-08-02 Thread Duncan Murdoch
On 02/08/2011 9:41 AM, Duncan Murdoch wrote: It looks to me as though your proposal would allow update to remove variables, but would give erroneous results when adding them. For example: mm- function(datf) { lm(y ~ x, data = datf) } mydatf- data.frame(x = rep(1:2, 10), y = rnorm(20,

Re: [Rd] update.default: fall back on model.frame in case that the data frame is not in the parent environment

2011-08-02 Thread Thaler, Thorn, LAUSANNE, Applied Mathematics
mm - function(datf) { lm(y ~ x, data = datf) } mydatf - data.frame(x = rep(1:2, 10), y = rnorm(20, rep(1:2, 10)), z = rnorm(20)) l - mm(mydatf) update(l, . ~ . + z) # This fails, z is not found Good point. So let me rephrase the initial problem: 1.) An lm object is fitted somewhere

Re: [Rd] update.default: fall back on model.frame in case that the data frame is not in the parent environment

2011-08-02 Thread Duncan Murdoch
On 02/08/2011 10:48 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics wrote: mm- function(datf) { lm(y ~ x, data = datf) } mydatf- data.frame(x = rep(1:2, 10), y = rnorm(20, rep(1:2, 10)), z = rnorm(20)) l- mm(mydatf) update(l, . ~ . + z) # This fails, z is not found Good point.