Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

r
math
ceiling
communitycreator

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

harris910

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))

RELATED TAGS

r
math
ceiling
communitycreator

CONTRIBUTOR

harris910
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time

Copyright ©2022 Educative, Inc. All rights reserved.