Learn R Programming

pretestcad (version 1.1.0)

round_to_nearest_digit: Round To Nearest Digit

Description

A function that does symmetric rounding to the nearest digits.

Usage

round_to_nearest_digit(number, digits = 0)

Value

A numeric value rounded off to a number of decimal places specified in the input digits.

Arguments

number

Input numeric value

digits

Input integer indicating the number of decimal places to be used. By default, it rounds off to the nearest integer. Default: 0

Examples

Run this code
round_to_nearest_digit(0.5)
round_to_nearest_digit(1.5)
round_to_nearest_digit(-0.5)
round_to_nearest_digit(-1.5)
round_to_nearest_digit(1021.125, digits = 2)

Run the code above in your browser using DataLab