4  Arithmetic Operations

+, -, *, /, ^ work in the same way as a calculator, e.g., exponentiate:

It also works with modulo: quotient – %/%, remainder – %%:

R uses functions to perform operations. To run a function called funcname, we type funcname(input1, input2), where the inputs (or arguments) input1 and input2 tell R how to run the function. A function can have any number of inputs. Maths functions such as Square root sqrt(), Logrithm log(), Exponentiation exp(), Absolute value abs() are built-in functions.

Exercise A

Q1

Calculate 20 mod 6 (i.e., the remainder of 20 divided by 6).

Q2

Calculate \((2+5)\) squared divided by \(3\times\sqrt{e^{2.4} - |8.6-9.2|}\).