In R, you can use operators to perform common mathematical operations on numbers.
+ operator is used to add together two values:
- operator is used for subtraction:
You will learn more about available operators in our R Operators Tutorial.
Built-in Math Functions
R also has many built-in math functions that allows you to perform mathematical tasks on numbers.
For example, the
max() functions can be used to find the lowest or highest
number in a set:
min(5, 10, 15)
sqrt() function returns the square root of
abs() function returns the absolute (positive) value of
ceiling() and floor()
ceiling() function rounds a number upwards to
its nearest integer, and the
function rounds a number downwards to its nearest integer, and returns the result: