PART 1 - BASIC ARITHMETIC OPERATIONS

R can be used as a calculator. The basic arithmetic operators are:

1. Addition (+)

## [1] 8

2. Substraction (-)

## [1] 2

3. Multiplication (*)

## [1] 15

4. Division (/)

## [1] 1.666667

5. Exponent (^)

## [1] 16

6. Remainder of division (%%)

## [1] 1

PART 2- BASIC ARITHMATIC FUNCTIONS

Logarithms and Exponentials

## [1] 3.321928
## [1] 1
## [1] 22026.47

Other mathematical functions

## [1] 5
## [1] 4

ASSIGNING VALUES TO VARIABLES

A variable can be used to store a value. For example, the R code below will store the price in a variable, say “price”:

Important Notes

Note that, it’s possible to use <- or = for variable assignments.

Note that, R is case-sensitive. This means that Price is different from price.

It’s possible to make some operations with it.

## [1] 21

You can change the value of the object:

## [1] 5

The following R code creates two variables holding the width and the height of a rectangle. These two variables will be used to compute the area of the rectangle.

## [1] 50