是否可以将na.rm全局设置为TRUE? [英] Is it possible to set na.rm to TRUE globally?

查看:78
本文介绍了是否可以将na.rm全局设置为TRUE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于像max这样的命令,默认情况下将na.rm选项设置为FALSE.我知道总体上为什么这是个好主意,但我想暂时将其关闭(即在会议期间).

For commands like max the option na.rm is set by default to FALSE. I understand why this is a good idea in general, but I'd like to turn it off reversibly for a while -- i.e. during a session.

无论如何,我如何要求R设置na.rm = TRUE?我发现

How can I require R to set na.rm = TRUE whenever it is an option? I found

options(na.action = na.omit)

但这是行不通的.我知道我可以为我编写的每个函数设置一个na.rm=TRUE选项.

but this doesn't work. I know that I can set a na.rm=TRUE option for each and every function I write.

my.max <- function(x) {max(x, na.rm=TRUE)}

但这不是我想要的.我想知道是否有什么我可以在全局/通用范围内做更多的事情,而不是对每个功能都做.

But that's not what I am looking for. I'm wondering if there's something I could do more globally/universally instead of doing it for each function.

推荐答案

无法全局将na.rm更改为TRUE. (请参阅在该问题下Hong Ooi的评论.)

It is not possible to change na.rm to TRUE globally. (See Hong Ooi's comment under the question.)

不幸的是,您不想要的答案是唯一可行的答案 一般来说.没有全局选项,例如 na.action,仅影响lm,glm等建模功能 (甚至在那里,也不能保证在所有情况下都能正常工作). –洪 Ooi 13年7月2日在6:23

Unfortunately, the answer you don't want is the only one that works generally. There's no global option for this like there is for na.action, which only affects modeling functions like lm, glm, etc (and even there, it isn't guaranteed to work in all cases). – Hong Ooi Jul 2 '13 at 6:23

这篇关于是否可以将na.rm全局设置为TRUE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆