[R] Help with na.action option

Thomas Lumley thomas at biostat.washington.edu
Fri Mar 10 02:17:53 CET 2000


On 9 Mar 2000, R.E. Darnell wrote:

> I would like to define my own na.action function to be used by the
> glm (actually slightly modified glm) function but I would like to
> return not just a data object but set other variables like
> control$maxit..
> 
> I have been able to achieve the initial bit (returning a new data
> object) but I am not sure how my na.my.action function can set
> these other variables.
> 
> I would appreciate any help on this

This is tricky because it's not supposed to happen that way.  na.action is
called right down in model.frame. The way we handle model formulas is that
model.frame is evaluated in the environment where glm is called, not in
the environment inside glm. This means that when na.action is called it
can't easily get to the environment where control$max.it lives.

Also, even if it were possible it probably wouldn't be the best solution
-- it's bad enough to mess with variables in the global environment using
<<-, but altering variables in non-nested environments is going to get
confusing very quickly.

It would be much easier to return the information as an attribute of the
model frame and then edit the source code of glm to extract that
information and use it to change control$maxit

	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list