bdLogical
with attributes preserved. The operators are and,
or, not, and exclusive or.
e1 & e2 e1 | e2 ! e1 xor(e1, e2)
bdLogical
objects. Missing values (
NA
s) are allowed.
An exclamation mark (!) beginning an expression always escapes to the operating system rather than meaning "not". Use curly braces or parentheses to surround an expression if the "not" operator is the first character.
The !, &, and | operators make up the
"Logic"
group of operators
within the
"Ops"
group.
The membership of this class is subject to change; in particular,
!
may be removed and
xor
added.
Results corresponding to
NA
in the operands will be either a logical value or an
NA
, depending on
whether the other operand uniquely determines the answer; for example,
NA|TRUE must be
TRUE
, and NA&FALSE must be
FALSE
.
See section 5.1.5 of Becker, Chambers and Wilks
for the rules for dealing with operands with attributes.
Logic
is a group generic function,
including a subset of
functions included under the
Ops
group generic function.
The current list of functions in this group may be found by
typing
getGroupMembers("Logic")
in the S-PLUS Commands window.
Additional information may be available for specific methods, via
methods?Logic
.
||
(sequential or) and
&&
(sequential and).
,
,
,
and individual functions listed below.
# The Ops group of generic functions includes: # Arithmetic: +, -, *, /, ^, %/%, %% # Comparison: >, <, >=, <=, ==, !=, compare # Logical: !, &, | # See also .Uminus and xor attach(cu.summary) # Cars made in USA or Japan or both: cu.summary[Country=="USA" | Country=="Japan/USA" | Country == "Japan", ] # Rows of cu.summary with no NA's in either Reliability or Mileage: cu.summary[!is.na(Reliability) & !is.na(Mileage),] # Cars with Mileages outside the interquartile range exclusive of NA's: safe <- !is.na(Mileage) cu.summary[xor(Mileage > 21, Mileage < 27) & safe, ] # A logic table for &: a <- c(T,F,NA) outer(a,a,"&")