Aug21W.ppt

Basics of R
Structures: vectors, matrices,
functions, lists (…more?)
Constants
• Usual: 2, -3, 7.5e-3, TRUE, “the quick brown
fox”
• Unusual: pi
Variables
• Scalar (vector!)
• Case sensisitve: x and X
• Names: this, that.one
Basic tools
•
•
•
•
•
Assignment: x <- 5
Arithmetic: +, -, *, /, ^
Comparison: <, <=, >, >=, ==, !=
Logical operators: & (and), | (or), ! (not)
Careful with rounding: .5 == (.1 + 2/5) and also
(.7 - .2) - .5 == 0
• Functions? Lots… start with sqrt(), sin(),
acos(), exp()