How to calculate the ceiling() of a value in R

The ceiling() function returns the smallest integer that is greater than or equal to the number whose ceiling needs to be calculated.

Figure 1 shows the mathematical representation of the ceiling() function and the corresponding expression in R.

Figure 1: Mathematical representation of ceiling() function and the corresponding expression in R

Syntax

ceiling(number)

Parameter

This function requires a number to round up as a parameter.

Return value

ceiling() returns the smallest integer that is greater than or equal to the number sent as a parameter.

Example

#Positive number
a <- ceiling(10);
print(paste0("ceiling(10): ", a))
b <- ceiling(5.3);
print(paste0("ceiling(5.3): ", b))
#negative number
c <- ceiling(-10);
print(paste0("ceiling(-10): ", c))
d <- ceiling(-5.3);
print(paste0("ceiling(-5.3): ", d))

Free Resources