Hello,
I'm running into what I believe is a scoping issue having to do with the
environment in which the weights argument is evaluated in lm.  From the lm
documentation "All of weights, subset and offset are evaluated in the same
way as variables in formula, that is first in data and then in the
environment of formula.".  In the code at http://pastebin.com/kqzxxicp I
have 3 functions identical to each other except for

WeightsBreaks adds "weights = someData$weight"
and
Works uses the <<- assignment operator for someData.

My interpretation of the quoted documentation above is that lm looks at the
data argument to find weights, subset and offset and then to the
environment in which the formula argument lives.  Am I missing something?
Why is it that lm only sees weights (here someData$weight) when it's in the
global environment, yet lm sees data (someData in this case) regardless of
whether it's in the global environment or just local to the function?
Thanks for your time.

Dave

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to