The two disagree on an exact half. Base R rounds a half to the even
digit (round(0.5) is 0, round(2.5) is 2); SAS's ROUND() rounds
it away from zero (0.5 is 1, 2.5 is 3, -0.5 is -1).
Every formatter in the package – fmt_signif(), fmt_round(),
fmt_numeric(), fmt_count_pct() – rounds with this same rule, so
a study that has to match a SAS-produced table sets it once:
options(rtfreporter.rounding = "sas")An explicit rounding = on any call still wins over the option.
"sas" also absorbs a binary representation error the way SAS's own
fuzz does: 2.675 is stored as 2.67499999999999982, which base R
rounds to 2.67 and SAS to 2.68.
These format numbers in a data frame or vector before a table is
built; the fmt_* functions as_rtftables()'s cell_format takes
(fmt_count_pct(), ...) format cells as the table is built.
Arguments
- x
A numeric vector.
- digits
Decimal places. Default
0.- rounding
"r"(base R, half to even) or"sas"(half away from zero), in either case ("SAS"is"sas"; so for the option and every function'srounding).NULL, the default, readsgetOption("rtfreporter.rounding"), which is"r"unless the session or site set it.
See also
fmt_round() for the same rounding as printed text.