R Tutorials
R Data Structures
R Graphics
R Statistics
R Examples
In R, you can use operators to perform common mathematical operations on numbers.
The + operator is used to add together two values:
10 + 5
And the - operator is used for subtraction:
10 - 5
R also has many built-in math functions that allows you to perform mathematical tasks on numbers.
For example, the min() and max() functions can be used to find the lowest or highest number in a set:
max(5, 10, 15)
min(5, 10, 15)
The sqrt() function returns the square root of a number:
sqrt(16)
The abs() function returns the absolute (positive) value of a number:
abs(-4.7)
The ceiling() function rounds a number upwards to its nearest integer, and the floor() function rounds a number downwards to its nearest integer, and returns the result:
ceiling(1.4)
floor(1.4)