Togaware DATA MINING
Desktop Survival Guide
by Graham Williams
Google

Logical

Objects of type logical take on the values TRUE or FALSE. The basic logical operators include:

! Not $<$ Less than $<=$ Less than or equal to
$==$ Equal to $>$ Greater than $>=$ Greater than or equal to
& And | Or && || Non vectorised versions



> 5 == 4        # FALSE
> 5 != 4 	# TRUE
> ! 1 - 1	# TRUE since 1-1 is 0 and is coerced to FALSE
> TRUE * 2	# 2 since TRUE is coerced to 1.

The single logical connectives & and | operates on vectors, whilst the double connective returns a single result, and does a minimal amount of comparison to get the result.

> c(TRUE, TRUE, FALSE) & c(TRUE, FALSE, FALSE)
[1]  TRUE FALSE FALSE
> c(TRUE, TRUE, FALSE) && c(TRUE, FALSE, FALSE)
[1] TRUE

The double form is usually what you want in an XnullXR functionsR functions (R function)R functionsR libraries (R library)R functionsR option (R option)R functionsR packages (R package)R functionsDatasets (Dataset)R functionsR functionsif statement.



Copyright © 2004-2008 Togaware Pty Ltd
Support further development through the purchase of the PDF version of the book.
PDF version is properly formatted and forms a comprehensive book (draft with over 600 pages).
Brought to you by Togaware.