Skip to content
Prev 359165 / 398502 Next

Lexical scoping for step and add1 functions

So in both my solution and your second option, lm prints that it evaluated the regression in a function context (using dfr) which the user of the function might prefer to be unaware of (they know what X.des is). Your first solution  avoids that but hardcodes access to the global variable so if the user wants to use a different data frame then a different function has to be defined. I am OK with that, but thought that there might be a way to indirectly tell lm to use the global environment via the parameter dfr.