Ch 7-8 Arithmetic Logical Operators © Fall 2004 Don Edwards and the University of South Carolina
7 Arithmetic Basic operators (+,-,…) Typical “calculator” functions (exp, log, sqrt, sum, prod, …) Matrices Elementwise and matrix operators Be careful of object type Maple users may be underwhelmed
8 Logical Objects and Operators TRUE or FALSE values Logical operators (>,<,>=,!,…) Subsetting and conditional execution Compound (&,|,..) and sequential (&&,||,…) operators With sequential operators, the second logical comparison can be skipped if the first is true. Not really evident in real time.
8 Logical Operators as functions xor any, all, identical,… Avoid == with numeric variables Don’s old notes had an advanced discussion of testing equivalency of numeric variables. Class Exercise 3 touches on this topic as well.
8 Conditional Execution if{…} else if{…} else {…} The if() statement works elementwise Wait till Chapter 10: Iteration ifelse() Excel recoding The syntax for if/else if/else is highly structured—very un-R like. Class Exercise 3 discusses ifelse()