Can I force R to use regular numbers instead of using the e+10
-like notation? I have:
1.810032e+09
# and
4
within the same vector and want to see:
1810032000
# and
4
I am creating output for an old fashioned program and I have to write a text file using cat
.
That works fine so far but I simply can't use the e+10
notation there.
It can be achieved by disabling scientific notation in R.
Put
options(scipen = 999)
in your .Rprofile file so it gets auto-executed by default. (Do not rely on doing it manually.)(This is saying something different to other answers: how?
This is a bit of a grey area. You need to recall that R will always invoke a print method, and these print methods listen to some options. Including 'scipen' -- a penalty for scientific display. From
help(options)
:Example:
That said, I still find it fudgeworthy. The most dire way is to use
sprintf()
with explicit width.My favorite answer:
This gives what you want without having to muck about in R settings.
Note that it returns a character string rather than a number object