Re: [R] Lexical scoping for step and add1 functions

2016-03-09 Thread Jeff Newmiller
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 t

Re: [R] Lexical scoping for step and add1 functions

2016-03-09 Thread S Ellison
> In a nutshell, formulas carry the environment in which they are defined along > with the variable names, and your dfr was defined in the test.FN environment, > but the formulas were defined in the global environment. I got this to work by > defining the formula character strings in the global env

Re: [R] Lexical scoping for step and add1 functions

2016-03-09 Thread Jeff Newmiller
In a nutshell, formulas carry the environment in which they are defined along with the variable names, and your dfr was defined in the test.FN environment, but the formulas were defined in the global environment. I got this to work by defining the formula character strings in the global environ

[R] Lexical scoping for step and add1 functions

2016-03-07 Thread Louisell, Paul T PW
Hi, I've run into a problem calling the step function from within a function; I sent this to the R development list first, but the moderator said it was better suited to R help. My OS is Windows 7 and I'm using R version 3.2.3. Here's a simple function to help reproduce the error: > test.