R provides a wide range of built-in math functions that can be used for complex calculations and mathematical operations. Some commonly used math functions in R include:
- sqrt(x): Calculates the square root of the given number.
- abs(x): Returns the absolute value of the given number.
- ceiling(x): Rounds the given number up to the nearest integer.
- floor(x): Rounds the given number down to the nearest integer.
These functions can be used to perform various mathematical operations and transformations in R. Here are some examples:
# Square root
result1 <- sqrt(16)
print(result1) # Output: 4
# Absolute value
result2 <- abs(-10)
print(result2) # Output: 10
# Ceiling
result3 <- ceiling(3.2)
print(result3) # Output: 4
# Floor
result4 <- floor(3.9)
print(result4) # Output: 3
Note: The examples above demonstrate the usage of individual math functions. However, these functions can be used in combination with other arithmetic operations and functions to perform more complex calculations.