View source: R/rounding_functions.R
roundpow | R Documentation |
roundpow
is a function that allows for traditional rounding of
numbers to a power of 10. The built in R rounding function
(round
) from the R base package follows the standard of the
IEC 60559 when determining how to round off the number 5. This rule states
that you 'go to the even digit'. This is different from how most
people learn to round off 5 in school (and different from how Excel rounds
numbers), with one rounding 5 off to the next highest absolute value
integer. The function roundup
in this package allows one to
apply the traditinal rounding measure. This function extends
roundup
by allowing one to round numbers to a power of 10.
roundpow(x, power = 1)
x |
a numeric vector. |
power |
positive integer indicating the power of ten to round too. |
numeric vector of x
rounded to the power of 10 specified by
power
.
Other Rounding functions:
roundup()
# Examples roundpow(125, power=1) roundpow(125, power=2) roundpow(10555, power=1) roundpow(10555, power=2) roundpow(10555, power=3) roundpow(10555, power=4) # Comparing IEEE Rounding vs. Traditional Rounding data(BSB) IEEE <- with(BSB, round(TL / 10) * 10) Trad <- with(BSB, roundpow(TL, 1)) plot(Trad ~ jitter(IEEE), xlab = "IEEE Total Length (mm)", ylab = "Traditional Total Length (mm)")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.