Section 3 Using R as a calculator
To do addition, subtraction, multiplication and division, use the symbols +
, -
, *
, /
respectively. For example, if you type 5 * 6
at the command prompt, and press return, you will see
## [1] 30
The symbol ^
is used for raising a number to a power. For example, to calculate \(2^4\), try the following
## [1] 16
3.1 Scientific notation
Large numbers may be displayed using “scientific notation”. For example, if we calculate \(500^3\) in R, instead of displaying 125000000
as the result, we see
## [1] 1.25e+08
When you see e
appear within a number, read it as “multiplied by 10 to the power of”. So 1.25e+08
is read as “1.25 multiplied by 10 to the power of 8”.