[R] Environment of a LM created in a function
Thaler, Thorn, LAUSANNE, Applied Mathematics
Thorn.Thaler at rdls.nestle.com
Tue Aug 2 11:02:03 CEST 2011
Dear Peter,
Thanks for your concise answer, it works perfectly.
By the way, I fully agree that "data" or "df" are not good names for
data.frames and I am/was aware of that and I usually avoid those names
(not consequently though I've to admit, it is too tempting ;). However,
if one uses those evil names, one cannot expect to receive meaningful
error messages. Thus, I was not astonished by the peculiar error message
itself (in fact I was well aware that this has to do with the bad naming
and the fact that "data" is, above all, a function) and I suspect the
error to be due to environment issues.
I tried the workaround with passing the very same data argument
explicitly to update:
> update(models[[1]], . ~ ., data = dat)
which worked but which left the stale impression of redundancy and even
more dangerous error proneness: what happens if the name of the data
frame is changed earlier?
Finally, your suggestion with
> update(models[[1]], . ~ ., data = model.frame(models[[1]]))
solved all the issues (and I was wondering why I did not try it out
myself, so obviously I was not seeing the wood for the trees). So,
thanks a lot for your help.
Have a nice day.
KR,
-Thorn
More information about the R-help
mailing list