2.9 Summary of Operators

Now we have fully introduced the first object—-vectors. You have learned how to create vectors and apply various operations on them. There are several different types of operators to conduct different operations in R. In this section, we want to give you a brief review of some operators and operations according to their types.

Let’s summarize the four types of operators we have learned. In the following parts, we will review each type one by one.

Operator Section
arithmetic operator 1.2
assignment operator 1.3
relational operator 2.6
logical operator 2.7

2.9.1 Arithmetic operator

Arithmetic operators (Section 1.2) are operators that often used to some basic calculations. The following is a list of operators available in R.

Operator Explanation
+ addition
- subtraction
* multiplication
/ division
%/% integer division
%% modulus
^ exponentiation

2.9.2 Assignment operator

The assignment operator (Section 1.3) is the perhaps the most fundamental operator. It can help you to create objects with names.

Operator Explanation
<- do object assignment

2.9.3 Relational operator

Relational operators are operators that are often used to do comparisons. The following is a list of operators available in R.

Operator Explanation
< less
<= less than or equal to
> bigger
>= bigger than or equal to
== equal to
!= not equal to

2.9.4 Logical operator

Logical operators are often used between two logical vectors when we want to do a particular vector subsetting. The following is a list of logical operators available in R.

Operator Explanation
! NOT
& AND
| OR
xor() Exculsive OR

In addition to using various operators to conduct operations, we can do much more using various functions in R.