ro | R Documentation |
Rounds a given number to given number of digits after the decimal point, returning it as string, with trailing zeros when applicable.
ro(num, round_to = 2, leading_zero = TRUE, signi = FALSE)
num |
Number to be rounded. |
round_to |
Number of fractional digits (i.e., digits after the decimal point), to round to. |
leading_zero |
Logical, |
signi |
Logical, |
Number as string: num
rounded to round_to
digits, with
trailing zeros when applicable.
ro( 1.2345 ) # returns "1.23" ro( 0.12345, 1 ) # returns "0.1" ro( 12.3, 4 ) # returns "12.3000" # examples with vectors to_round = c(1000, 100, 0.1, 0.01, 0.001, 0.0001) ro(to_round) ro(to_round, 3) ro(to_round, 3, leading_zero = FALSE) ro(to_round, 3, signi = TRUE) to_round2 = c(1230.000, 100, 0.012, 0.01, 0.123, 0.012340) ro(to_round2, 3) ro(to_round2, 3, signi = TRUE) ro(to_round2, 2, signi = TRUE) ro(to_round2, 1, signi = TRUE) ro(to_round2, 9, signi = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.