Skip to content
Prev 180377 / 398503 Next

specify the number of decimal numbers

(Ted Harding) wrote:
r's printing routines (e.g., print, sprintf, cat, anything else?) seem
to rely on the underlying c sprintf, with no prior r-implemented
rounding.  hence they import into r whatever standards-related problems
may the c counterpart have.
why math.h?
indeed.  i posted a similar example in reaction to the original 'excel
bug' response.
it does (seems to), but probably shouldn't, if excel bugs are to be
avoided.  however, passing the input from sprintf('%.1f', x) through
round to do the rounding would require some work to first parse the
format and decide the number of decimal digits.  not that it's undoable.

vQ