fmt | R Documentation |
Rounds and adds trailing zeros (by default if digits is lower than 4).
fmt(x, digits = 2L, zeros = digits < 4L, ...)
x |
numeric: vector. |
digits |
integer: Digits that should be used for rounding. |
zeros |
logical: Should trailing zeros be added? |
... |
passed to format for |
formatted x
as text.
Similar to function fmt
from the package exams.
In the function round2
has been replaced by round
.
exams::fmt
## this is also employed internally in the fmt() formatting function fmt(c(0.005, 0.015)) ## the main purpose of fmt() is that some numeric result can be displayed ## both at high accuracy and then at the rounding that students should do ## (e.g., with 2 or 3 digits) sol <- runif(1) fmt(sol, 6) fmt(sol, 2) ## but fmt() also assures showing a very high number of significant digits ## (up to 12) sol <- 123456 + sol sol fmt(sol, 6) fmt(sol, 2) ## and fmt() also takes care of adding trailing zeros (if digits < 4) fmt(1) fmt(1, digits = 3) fmt(1, digits = 6)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.