We will first see the basic arithmetic operations in R. The following operators stand for:
Operator | Description |
---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
^ or ** | Exponentiation |
Example 1:
# An addition
3 + 4
Output:
## [1] 7
You can easily copy and paste the above R code into Rstudio Console. The output is displayed after the character #. For instance, we write the code print('Guru99') the output will be ##[1] Guru99.
The ## means we print an output and the number in the square bracket ([1]) is the number of the display
The sentences starting with # annotation. We can use # inside an R script to add any comment we want. R won't read it during the running time.