Create or test for objects of type
"logical", and the basic
TRUE FALSE T; F logical(length = 0) as.logical(x, ...) is.logical(x)
A non-negative integer specifying the desired length. Double values will be coerced to integer: supplying an argument of length other than one is an error.
object to be coerced or tested.
further arguments passed to or from other methods.
FALSE are reserved words denoting logical
constants in the R language, whereas
F are global
variables whose initial values set to these. All four are
Logical vectors are coerced to integer vectors in contexts where a
numerical value is required, with
TRUE being mapped to
logical creates a logical vector of the specified length.
Each element of the vector is equal to
as.logical attempts to coerce its argument to be of logical
type. In numeric and complex vectors, zeros are
non-zero values are
factors, this uses the
as.vector it strips attributes including
names. Character strings
c("T", "TRUE", "True", "true") are
regarded as true,
c("F", "FALSE", "False", "false") as false,
and all others as
FALSE depending on
whether its argument is of logical type or not.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
NA, the other logical constant.
Logical operators are documented in
## non-zero values are TRUE as.logical(c(pi,0)) if (length(letters)) cat("26 is TRUE\n") ## logical interpretation of particular strings charvec <- c("FALSE", "F", "False", "false", "fAlse", "0", "TRUE", "T", "True", "true", "tRue", "1") as.logical(charvec) ## factors are converted via their levels, so string conversion is used as.logical(factor(charvec)) as.logical(factor(c(0,1))) # "0" and "1" give NA
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.