-1

I have a number which show as

a <- 1.34467773e-5. 

I want to format it to

a <- 1.34e-5. 

How can I do it?

Thanks.

Wang
  • 1,314
  • 14
  • 21

2 Answers2

2
formatC(a, format = "e", digits = 2)
Felipe Alvarenga
  • 2,572
  • 1
  • 17
  • 36
  • It's unclear in the question if the desired output is `numeric` or `character`, this is the latter. G5W's comment is the former. – r2evans Mar 25 '19 at 18:34
0

You could also use the function sprintf. For example:

sprintf("%.1e", 0.00008765)
Paggles01
  • 81
  • 4