[R] The use of F for False and T for True

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Mon Nov 17 10:21:52 CET 2008


Rolf Turner wrote:
> (Note:  You *cannot* have spurious objects name "FALSE" (and not equal
> to FALSE) hanging around; R won't let you.  That's why you use FALSE and
> not F.)

yes you can, r will let you:

assign("FALSE", TRUE)
ls()
# see "FALSE"
get("FALSE")
# see TRUE

this does not matter much, as r will think FALSE when you type FALSE,
rather than look up your variable, and you'd have to use backticks to
get the latter.  but you may want to be more careful when playing with
promises and deparsing them in your functions:

f = function(n, m, replace, env) {
   replace = get(deparse(substitute(replace)), env)
   sample(1:n, m, replace=replace)
}

f(n = 10, m = 100, replace = FALSE, env = e)
# given the above, succeeds


this is a rather silly example and you're unlikely to meet the problem
in practice, but it is *not* impossible.  knowing only the interface to
f and not its implementation may lead you to an incorrect assumption
about the meaning of FALSE inside f.

vQ



More information about the R-help mailing list