[R] Global setting for na.rm=TRUE

Gabor Grothendieck ggrothendieck at gmail.com
Tue Aug 1 15:38:54 CEST 2006


There is a global option setting for na.action.  See ?na.action .
That does not completely address your question but might
help with lm, glm, etc.

You could define your own wrapper functions if you know ahead of time
which functions with na.rm= args you need. e.g.

my.max = function(..., na.rm = getOption("na.rm")) max(..., na.rm = na.rm)
getOption("na.rm") # NULL
my.max(1, 2, NA) # 2
options(na.rm = FALSE)
my.max(1,2,NA) # NA

On 8/1/06, Gorjanc Gregor <Gregor.Gorjanc at bfro.uni-lj.si> wrote:
> Hello!
>
> Is it possible to set na.rm=TRUE in a global way? I'am constantly
> forgeting on this when performing analyses. I agree that one should
> be carefull with this when developing some code, but not necesarilly
> so in data analysis.
>
> Lep pozdrav / With regards,
>    Gregor Gorjanc
>
> ----------------------------------------------------------------------
> University of Ljubljana     PhD student
> Biotechnical Faculty        URI: http://www.bfro.uni-lj.si/MR/ggorjan
> Zootechnical Department     mail: gregor.gorjanc <at> bfro.uni-lj.si
> Groblje 3                   tel: +386 (0)1 72 17 861
> SI-1230 Domzale             fax: +386 (0)1 72 17 888
> Slovenia, Europe
> ----------------------------------------------------------------------
> "One must learn by doing the thing; for though you think you know it,
>  you have no certainty until you try." Sophocles ~ 450 B.C.
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list