R is an extremely powerful tool, however, still it can be used just as any calculator. Write the commands directly into your console (by default this is the lower left window in your RStudio environment) or write down the commands in your editor (by default this is the upper left window in your RStudio environment).

Note that # is a comment and will be ignored by R

# 1 + 1 ... the line will be ignored

We can do any type of arithmetic computation

## [1] 103
## [1] 25
## [1] 6.5

Note that there is an order of operations, also referred to as operator precedence, which corresponds to a collection of rules that reflect conventions about which procedures to perform first in order to evaluate a given mathematical expression.

For instance

## [1] 16

is not the same as

## [1] 26

In R the following unary and binary operators are defined. They are listed in precedence groups, from highest to lowest.

\[\begin{array}{r|l} \text{::} \quad \text{:::}&\text{access variables in a namespace}\\ \$ \text{ @} & \text{component / slot extraction}\\ \text{[} \quad \text{[[} & \text{indexing}\\ \text{^} &\text{exponentiation (right to left)}\\ \text{- +}&\text{unary minus and plus}\\ \text{:}&\text{sequence operator}\\ \text{%any%}&\text{special operators (including %% and %/%)}\\ \text{* /}&\text{multiply, divide}\\ \text{+ -}&\text{(binary) add, subtract}\\ \text{< > <= >= == !=}&\text{ordering and comparison}\\ \text{!}&\text{negation}\\ \text{&} \quad \text{&&}&\text{and}\\ \text{|} \quad \text{||}&\text{or}\\ \text{~}& \text{as in formulae}\\ \text{->} \quad \text{->>}&\text{rightwards assignment}\\ \text{<-} \quad \text{<<-}&\text{assignment (right to left)}\\ \text{=}&\text{assignment (right to left)}\\ \text{?}&\text{help (unary and binary)}\\ \end{array}\]

The symbol * means multiply, and ^ means “to the power”, so this gives 2 times 10 squared, i.e. 200

## [1] 200

R knows about infinity (and minus infinity)

## [1] Inf

Undefined results take the value NaN (“not a number”)

## [1] NaN