Learn R Programming

cuadramelo (version 1.0.0)

round_vector: Round univariate

Description

Rounds a vector preserving the rounded sum.

Usage

round_vector(x, digits = 0)

Value

description

Arguments

x

A vector.

digits

Number of decimal places to be rounded to.

Examples

Run this code
set.seed(4)
x <- (rnorm(5)*10) |> abs()
y <- round_vector(x)
cbind(x, y)
round(sum(x)) - sum(y)

Run the code above in your browser using DataLab