These functions provide rounding and formatting similar to exams::round2 and exams::fmt.
round2 performs half-up rounding with a small offset to avoid rounding errors.
fmt formats numbers as character strings with a specified number of decimal places.
round2(x, digits = 0)fmt(x, digits = 2L, zeros = digits < 4L, ...)
round2 returns a numeric vector rounded to the specified number of digits.
fmt returns a character vector with numbers formatted as strings with the requested number of decimal places.
Numeric vector to be rounded or formatted.
Integer, number of decimal places. Default is 0 for round2, 2 for fmt.
Logical, whether to keep trailing zeros. Default is TRUE if digits < 4 (fmt only).
Additional arguments passed to format() (fmt only).
Adapted from exams package by R. Schwabe et al.
round2, fmt from the exams package.