使用T& amp;有什么问题吗? F代替TRUE&错误的? [英] Is there anything wrong with using T & F instead of TRUE & FALSE?
问题描述
我注意到在R中的函数中使用T
和F
而不是TRUE
和FALSE
可以得到相同的结果.当然,T
和F
更简洁,但是,我看到TRUE
和FALSE
的使用频率更高.
I noticed that using T
and F
instead of TRUE
and FALSE
in functions in R gives me the same results. Of course, T
and F
are more concise, yet, I see TRUE
and FALSE
being used more often.
我想知道两者之间是否有区别?使用T
和F
有什么问题吗?
I was wondering whether there is any difference between the two? Is there anything wrong with using T
and F
?
推荐答案
T
和F
,但是TRUE
和FALSE
是保留字,不能重新定义. >
T
and F
can be re-defined, but TRUE
and FALSE
are reserved words and cannot be re-defined.
> TRUE <- 1L
Error in TRUE <- 1L : invalid (do_set) left-hand side to assignment
> FALSE <- 0L
Error in FALSE <- 0L : invalid (do_set) left-hand side to assignment
> T <- F # yikes, this would be hard to debug!
就我个人而言,当我交互式使用R时,有时会使用T
和F
,但是我从不在生产代码或程序包中使用它们.
Personally, I sometimes use T
and F
when I use R interactively, but I never use them in production code or packages.
这篇关于使用T& amp;有什么问题吗? F代替TRUE&错误的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!