Skip to content

help with e+01 number abbreviations

3 messages · Gian Maria Niccolò Benucci, Petr Savicky, Greg Snow

#
On Thu, Feb 16, 2012 at 10:17:09AM +0100, Gian Maria Niccol? Benucci wrote:
Hi.

The exponential format was used probably due to some small
numbers. For example

  tst <- rbind(
  c( 5.0000e+00, 6.4836e+01, 9.5412e+01, 6.7753e+02, 8.7398e+01, 436.99),
  c( 2.0000e+00, 4.0747e+01, 1.0000e+02, 0.0000e+00, 1.0000e+02, 200.00),
  c( 3.0000e+00, 4.5381e+01, 7.7652e+01, 2.8075e+02, 8.8152e+01, 264.46),
  c( 1e-8,       1e-8,       1e-8,       1e-8,       1e-8,       1 ))

  tst

        [,1]       [,2]       [,3]       [,4]       [,5]   [,6]
  [1,] 5e+00 6.4836e+01 9.5412e+01 6.7753e+02 8.7398e+01 436.99
  [2,] 2e+00 4.0747e+01 1.0000e+02 0.0000e+00 1.0000e+02 200.00
  [3,] 3e+00 4.5381e+01 7.7652e+01 2.8075e+02 8.8152e+01 264.46
  [4,] 1e-08 1.0000e-08 1.0000e-08 1.0000e-08 1.0000e-08   1.00

Try roudning the numbers, for example

  round(tst, digits=4)

       [,1]   [,2]    [,3]   [,4]    [,5]   [,6]
  [1,]    5 64.836  95.412 677.53  87.398 436.99
  [2,]    2 40.747 100.000   0.00 100.000 200.00
  [3,]    3 45.381  77.652 280.75  88.152 264.46
  [4,]    0  0.000   0.000   0.00   0.000   1.00

Alternatively, options(scipen=20) forces a fixed point printing
with more digits.

  options(scipen=20)
  tst

             [,1]        [,2]         [,3]         [,4]         [,5]   [,6]
  [1,] 5.00000000 64.83600000  95.41200000 677.53000000  87.39800000 436.99
  [2,] 2.00000000 40.74700000 100.00000000   0.00000000 100.00000000 200.00
  [3,] 3.00000000 45.38100000  77.65200000 280.75000000  88.15200000 264.46
  [4,] 0.00000001  0.00000001   0.00000001   0.00000001   0.00000001   1.00

Hope this helps.

Petr Savicky.
#
Also look at the zapsmall function.  A useful but often overlooked tool.
On Thu, Feb 16, 2012 at 2:54 AM, Petr Savicky <savicky at cs.cas.cz> wrote: