## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Appendix A. Useful Operators and Functions in R

The commonly used operators in R are tabularized as follows:

Operator

Purpose

Example

`=`

Assignment

```> sum(a = 5, b = 6)
[1] 11
```

`<-`

Assignment

```> a <- 5
```

`+`

```> 10 + 1
[1] 11
```

`-`

Subtraction

```> 10 - 1
[1] 9
```

`*`

Multiplication

```> 10 * 2
[1] 20
```

`/`

Division

```> 10 / 2
[1] 5
```

`^ or **`

Exponentiation

```> 10 ^ 2
[1] 100
```

`x %% y`

Modulus (x mod y)

```> 11 %% 2
[1] 1
```

`x %/% y`

Integer division

```> 10 %/% 3
[1] 3
```

`<`

Less than

```> 3 > 5
[1] FALSE
```

`<=`

Less than or equal to

```> 3 <= 5
[1] TRUE
```

`>`

Greater than

```> 3 < 5
[1] TRUE
```

`>=`

Greater than or equal to

```> 3 >= 5
[1] FALSE
```

`==`

Check equality

```> 3 == 5
[1] FALSE
```

`!=`

Not equal to

```> 3 != 5
[1] TRUE
```

`!`

NOT

```> !a
```

`|`

OR

```> x | y
```

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required