Skip to content
Prev 40923 / 63424 Next

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

On 02/08/2011 10:48 AM, Thaler,Thorn,LAUSANNE,Applied Mathematics wrote:
I don't think so.  You can get the environment in which the formula was 
created from the "terms" component of the result; that's the second 
place lm() will look.  The first place it will look is in the explicitly 
specified data variable, and you can get its name, but I don't think the 
result object necessarily stores the full "data" argument or the 
environment in which to look it up.  (In your example, you can look up 
"datf" in environment(l$terms) and get it, but that wouldn't work if the 
formula had also been specified as an argument to mm().)
I would suggest something simpler:  return a list containing both l and 
datf, and pass datf to update.  You can attach a class to that list to 
hide some of the ugliness if you like.

Duncan Murdoch