
A-208 R AS A PROGRAMMING LANGUAGE AND ENVIRONMENT
A.11 Operators
Expressions in R can be composed of objects and operators. The following table of operators is
ordered by precedence (highest rank on top). See help(Syntax).
Basic R operators
$ select component by name.
Example: list$item
[ [[ indexing, access to elements.
Example: x[i]
^ exponentiation (right to left).
Example: x^3
- unary minus.
: sequence generation.
Examples: 1:5
5:1
%hnamei% special operators. Can also be user defined.
Examples: "%deg2%"<-function(a, b) a + b^2
2 %deg2% 4
* / multiplication, division.
+ - addition, subtraction.
< > < = > = ==
!=
comparison operators.
! negation.
& | && || and,