Learn R Programming

rray (version 0.0.0.9000)

rray_ceiling: Rounding functions

Description

  • rray_ceiling() - Compute the smallest integer value not less than x.

  • rray_floor() - Compute the largest integer value not greater than x.

  • rray_trunc() - Compute the nearest integer value not greater in magnitude than x.

  • rray_round() - Round x to the specified number of decimal places. Rounding is done towards the even digit, see base::round() for more information.

  • rray_signif() - Round x to the specified number of significant digits.

Usage

rray_ceiling(x)

rray_floor(x)

rray_trunc(x)

rray_round(x, digits = 0)

rray_signif(x, digits = 6)

Arguments

x

A vector, matrix, array or rray.

digits

An integer indicating the number of decimal places or significant digits to be used when rounding.

Examples

Run this code
# NOT RUN {
x <- matrix(c(2.22, 4.5, 5.5))

# Round up
rray_ceiling(x)

# Round down
rray_floor(x)

# Truncate towards 0
rray_trunc(x)
rray_trunc(-x)

# Round to the specified number of decimal
# places. Border values (on a `5`) are rounded
# towards even numbers
rray_round(x)
rray_round(-x)

rray_round(x, digits = 1)

# Two significant digits
rray_signif(x, 2)

# }

Run the code above in your browser using DataLab