round_to: Round numbers to a fixed number of decimal places

View source: R/number_tools.R

round_toR Documentation

Round numbers to a fixed number of decimal places

Description

Round numbers to a fixed number of decimal places

Usage

round_to(x, digits = 2)

Arguments

x

(Numeric) A vector of numbers.

digits

(Numeric) Number of decimal places to keep.

Value

A numeric vector.

Authors

Source

https://stackoverflow.com/a/12135122

Examples

vec <- c(1.739006, 2, -1.4, 1.05, 1.90, 3.826)
round_to(vec, digits = 3)
#> [1] "1.739"  "2.000"  "-1.400" "1.050"  "1.900"  "3.826" 


DesiQuintans/desiderata documentation built on April 9, 2023, 5:43 a.m.