logical. There is a big data analog; see
.
logical(length = 0) is.logical(x) as.logical(x)
logical returns a simple object of mode
"logical",
and the length specified.
is.logical returns
TRUE if
x has mode
"logical". Otherwise, it returns
FALSE.
Its behavior is unaffected by any attributes of
x; for example,
x could be a logical array (in contrast to the behavior of
is.vector).
as.logical returns
x if
x is a simple object
of mode
"logical". Otherwise, it returns a logical object of the
same length as
x and with data resulting from coercing the elements
of
x to mode
"logical".
bdLogical to a
logical, you must call
bd.coerce.
Logical objects are coerced automatically to numeric for arithmetic
and other numeric computations. In the coercion,
TRUE becomes
1 and
FALSE
becomes
0.
Conversely, numeric objects are coerced to logical by setting all
non-zero values to
TRUE. Note that there is no allowance for rounding
error in doing this, so it is not a good practice, except for
computations known to have integer results.
When a vector of mode
"character" is passed to it,
as.logical
coerces the character strings
"F" and
"FALSE" (without
regard to the case of the letters) to
FALSE, the character strings
"T"
and
"TRUE" (again, without regard to case) to
TRUE, and all other
strings to
NA.
Note the difference between coercing to a simple object of mode
"logical"
and setting the mode attribute:
mode(myobject) <- "logical"
This changes the mode of
myobject but leaves all other attributes unchanged
(so a matrix stays a matrix). The value of
as.logical(myobject)
has no attributes.
zz <- c(1, 2, 3, 4, 5) # sample object
logical(length(zz)) # logical object same length as zz
.Fortran("mysub", as.logical(xm))
as.logical(c("T", "F", "T", "T"))