Learn R Programming

xefun (version 0.1.5)

ceiling2: rounding of numbers

Description

The ceiling2 is ceiling of numeric values by digits. The floor2 is floor of numeric values by digits.

Usage

ceiling2(x, digits = 1)

floor2(x, digits = 1)

Value

ceiling2 rounds the elements in x to the specified number of significant digits that is the smallest number not less than the corresponding elements.

floor2 rounds the elements in x to the specified number of significant digits that is the largest number not greater than the corresponding elements.

Arguments

x

a numeric vector.

digits

integer indicating the number of significant digits.

Examples

Run this code
x = c(12345, 54.321)

ceiling2(x)
ceiling2(x, 2)
ceiling2(x, 3)

floor2(x)
floor2(x, 2)
floor2(x, 3)

Run the code above in your browser using DataLab