decimal: decimal() takes any numeric variable with decimal places, and...

View source: R/decimal.R

decimalR Documentation

decimal() takes any numeric variable with decimal places, and returns its aproximation of decimal places to a given number.

Description

decimal() takes any numeric variable with decimal places, and returns its aproximation of decimal places to a given number.

Usage

decimal(x, k)

Arguments

x

a numeric vector of a single variable

Details

simple wrapper for 'format(round(x, k), nsmall=k)' function, to format decimal numbers

Value

a string containing a numeric value, with a given number of decimals

Examples


number_with_decimals <- .5838
number_with_two_decimals <- decimal(number_with_decimals,2)
# result is .58
number_with_two_decimals

dacarras/r4sda documentation built on Nov. 9, 2023, 10:17 a.m.