condition function creates a condition for a user-defined format.
It is typically used in conjunction with the
condition(expr, label, order = NULL)
A valid R expression. The value in the expression is identified
by the variable 'x', i.e. x == 'A' or x > 3 & x < 6. The expression
should not be quoted. The expression parameter will accept equality,
relational, and logical operators. It will also accept numeric or string
literals. String literals should be quoted. It will not accept functions
or any expression that includes a comma. For these more complex operations,
it is best to use a vectorized function. See
A label to be assigned if the expression is TRUE. The label can any valid literal value. Typically, the label will be a character string. However, the label parameter does not restrict the data type. Meaning, the label could also be a number, date, or other R object type.
An optional integer order number. When used, this parameter
will effect the order of the labels returned from the
The new condition object.
condition function creates a condition as part of a format
definition. The format is defined using the
function. The condition is defined as an expression/label pair. The
expression parameter can be any valid R expression. The label parameter
can be any valid literal. Conditions are evaluated in the order they
are assigned. A default condition is created by assigning the expression
parameter to TRUE. If your data can contain missing values, it is
recommended that you test for those values first. Any data values that
do not meet one of the conditions will fall through the format as-is.
The condition object is an S3 class of type "fmt_cond". The condition
labels can be extracted from the format using the
The format object may be applied to a vector using the
fapply for further details.