2

Sometimes R abbreviates a double with e+/-XX e. g. 4.940082e+01. Because I need to write down some of those numbers I always need to add/substract zeros after/before the .. How can I force the R output to be 49.40082?

Here’s an example:

a <- c(4.940082e+01, 4.011437e+02, 2.497144e+03, 1.952008e+02, 7.856008e+02,
3.413898e+01, 1.693910e+03, 1.728184e+01, 1.508768e+03, 8.385327e+01, 
5.482288e+02, 2.000204e+00, 5.754306e+01, 5.101145e+02, 1.948592e+01, 
1.851458e+03, 2.022429e+03, 9.942939e+01, 5.276865e+02, 8.163265e-04, 
1.034082e+03, 4.063104e+02, 6.653898e+01, 5.684818e+02, 3.669961e+02, 
1.326000e+03, 1.302859e+02, 5.754306e+01, 4.237716e+02, 1.647200e+03)
lord.garbage
  • 5,884
  • 5
  • 36
  • 55

1 Answers1

1
as.numeric(format(4.940082e+01))
[1] 49.40082
nrussell
  • 18,382
  • 4
  • 47
  • 60
  • Yes, but this will only work for single numbers I type directly into the command line. And in this case you won’t even need `as.numeric(format())`. I’ll include an example to show what I mean. – lord.garbage Jul 14 '14 at 20:24