R is fundamentally designed for mathematics and highly advanced statistical analysis.
It provides a vast library of built-in math functions that are incredibly easy to use.
As we saw previously, you can simply type mathematical expressions using operators like +, -, *, and /.
However, for more complex equations, you rely heavily on built-in math functions.
The max() and min() functions rapidly find the highest or lowest value in a provided list of numbers.
The sqrt() function precisely calculates the square root of a specific number.
The abs() function instantly returns the absolute (positive) value of a number.
# Finding the maximum value highest_value <- max(5, 10, 15) print(highest_value) # 15 # Finding the square root square_root <- sqrt(16) print(square_root) # 4 # Absolute positive value absolute_val <- abs(-4.7) print(absolute_val) # 4.7
When dealing with decimals, you frequently need to round them to whole integers.
The ceiling() function explicitly rounds a number upwards to its nearest whole integer.
The floor() function explicitly rounds a number downwards to its nearest whole integer.
Which function returns the highest number in a specified list?
Which function forces a decimal number to strictly round UPWARDS to the nearest whole integer?