[Rd] Feature Request: Allow Underscore Separated Numbers

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Fri Jul 15 12:01:57 CEST 2022


On 14/07/2022 3:53 p.m., Devin Marlin wrote:
> Hello,
> 
> After using R for a number of years, and venturing into other languages,
> I've noticed the ones with the ability to enter numbers separated by
> underscores for readability (like 100000 as 100_000) make life a whole lot
> easier, especially when debugging. Is this a feature that could be
> implemented in R?

I think this could be done, but I doubt if anyone who could make the 
change would think the arbitrary decisions and added complexity in the 
parser was worth the effort.  (Would it be a thousands separator, or 
could it separate any number of digits?  Could a number start with an 
underscore or end with one?)

Instead, I'd suggest creating variables with meaningful names to hold 
big numeric constants, e.g.

     AU_in_km <- 149598262  # or 149.598262e6

     Jupiter <- 5.2 * AU_in_km

rather than

     Jupiter <- 5.2 * 149_598_262

Duncan Murdoch



More information about the R-devel mailing list