Force R not to use exponential notation (e.g. e+10)?

Answer

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):

‘scipen’: integer. A penalty to be applied when deciding to print numeric values in fixed or exponential notation. Positive values bias towards fixed and negative towards scientific notation: fixed notation will be preferred unless it is more than ‘scipen’ digits wider.

Example:

R> ran2 <- c(1.810032e+09,4) 
R> options("scipen"=-100,"digits"=4)
R> ran2
[1]1.81e+094.00e+00
R> options("scipen"=100,"digits"=4)
R> ran2
[1]18100320004

That said, I still find it fudgeworthy. The most dire way is to use sprintf() with explicit width.

All r Questions

Ask your interview questions on r

Write Your comment or Questions if you want the answers on r from r Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---