0

I have a minor technical problem:

I would like to specify the number of decimal places of whole numbers. For example I have the number "5000". After a mathematical operation in R, I would like to read "5000.0000".

I tried my best with the usual weapons of choice like "round" and "digit", but these functions are not strict enough for whole numbers.

Is there a way to circumvent R's default options?

Comment: I am aware that you can convert the number to a character class with respective decimal places, but I need a number class for a logical operation.

Best and many thanks!

Arne
  • 337
  • 1
  • 6
  • 17
  • Please provide a reproducible example to show how `round` fails. – lmo Nov 23 '16 at 13:11
  • Please clarify your comment, what logical operation? – zx8754 Nov 23 '16 at 13:13
  • 1
    re "But I need a number class for a logical operation." Then you're missing the point, viewing 5000.000 is viewing a character representation, R won't by default show you that, it's just text formatting. check your variable class, if it's num, it's a floating point and that's OK. – Tensibai Nov 23 '16 at 13:13
  • 1
    There are a number of misconceptions in your question. You seem to be not aware of the difference between what is printed and the internal representation, let alone of [floating point issues when comparing numbers](http://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal). – Roland Nov 23 '16 at 13:14

0 Answers0