# 3 First Operations

In this lesson we learn how to calculate Mathematical expressions, as well as store its results in a R object.

## 3.1 Common Mathematical Expressions

Let’s start by using R as a simple calculator in the console directly. So, type in the top-right panel the following expression:

 7

Now, how about other, still very simple, operations?

 12

Division

 0.75

Exponentiation

 81

Square Root

 13

Natural logarithm

 2.302585

Common logarithm

 1

Use round brackets to group operations so that they are carried out first

 34

What would happen if the round brackets were omitted?

 100.6667

The argument of a function can contain arithmetic operations or mathematical expressions

 4

Note that in R, you should only use parenthesis (or round brackets) but not square brackets for expressions in R.

 19

Another way to ask for R to evaluate (calculate) an expression or piece of code is to select it, and click on the Run button on the right side of the first pane. Or, while selected, press Ctrl + Enter on your keyboard. Let’s see if we can reproduce the following expression in the “Source” pane (top-left), if you do it correctly, you should find 0.2193828. $[ (2^3 - 1) - log(10) ] / (3 + \sqrt{7^3 - 4})$

Lastly, there are some named objects that R provides you, like the constant $$\pi$$ or Month names and letters.

 3.141593
  "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov"
 "Dec"
  "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q"
 "R" "S" "T" "U" "V" "W" "X" "Y" "Z"