From m@rc_@chw@rtz @end|ng |rom me@com  Sat Mar 23 01:06:20 2019
From: m@rc_@chw@rtz @end|ng |rom me@com (Marc Schwartz)
Date: Fri, 22 Mar 2019 20:06:20 -0400
Subject: [Rd] prettyNum digits=0 not compatible with scientific notation
In-Reply-To: <C5DDCC68-3180-44B2-941C-E1C58E86491B@gmail.com>
References: <30D28A63376088428E8318DD67FD407FCADD67@ny-mailstore1.walleyetrading.net>
 <23700.42650.645514.620943@stat.math.ethz.ch>
 <AAF25F95-1DDD-4C41-8132-54259D09679C@gmail.com>
 <23701.5710.730216.751381@stat.math.ethz.ch>
 <C5DDCC68-3180-44B2-941C-E1C58E86491B@gmail.com>
Message-ID: <3B191511-B121-4BEC-9E11-8900E38F8706@me.com>



> On Mar 22, 2019, at 7:25 PM, peter dalgaard <pdalgd at gmail.com> wrote:
> 
> 
> 
>> On 22 Mar 2019, at 18:07 , Martin Maechler <maechler at stat.math.ethz.ch> wrote:
>> 
>> gives (on Linux R 3.5.3, Fedora 28)
>> 
>>      d=10         d=7          d=2      d=1     d=0       
>> [1,] "123456"     "123456"     "123456" "1e+05" "%#4.0-1e"
>> [2,] "12345.6"    "12345.6"    "12346"  "12346" "%#4.0-1e"
>> [3,] "1234.56"    "1234.56"    "1235"   "1235"  "1235"    
>> [4,] "123.456"    "123.456"    "123"    "123"   "123"     
>> [5,] "12.3456"    "12.3456"    "12"     "12"    "12"      
>> [6,] "1.23456"    "1.23456"    "1.2"    "1"     "1"       
>> [7,] "0.123456"   "0.123456"   "0.12"   "0.1"   "0"       
>> [8,] "0.0123456"  "0.0123456"  "0.012"  "0.01"  "0"       
>> [9,] "0.00123456" "0.00123456" "0.0012" "0.001" "0"       
>> 
>> but probably looks better on Mac
> 
> 
> Yes (3.5.1 though)
> 
>> nn <- 123456*10^(0:-8); dd <- c(10, 7, 2:0); names(dd) <- paste0("d=",dd)
>> sapply(dd, function(dig) sapply(nn, format, digits=dig))
>      d=10         d=7          d=2      d=1     d=0     
> [1,] "123456"     "123456"     "123456" "1e+05" "1.e+05"
> [2,] "12345.6"    "12345.6"    "12346"  "12346" "1.e+04"
> [3,] "1234.56"    "1234.56"    "1235"   "1235"  "1235"  
> [4,] "123.456"    "123.456"    "123"    "123"   "123"   
> [5,] "12.3456"    "12.3456"    "12"     "12"    "12"    
> [6,] "1.23456"    "1.23456"    "1.2"    "1"     "1"     
> [7,] "0.123456"   "0.123456"   "0.12"   "0.1"   "0"     
> [8,] "0.0123456"  "0.0123456"  "0.012"  "0.01"  "0"     
> [9,] "0.00123456" "0.00123456" "0.0012" "0.001" "0"  
> 


Here is 3.5.3 on macOS:

> nn <- 123456*10^(0:-8); dd <- c(10, 7, 2:0); names(dd) <- paste0("d=",dd)
> sapply(dd, function(dig) sapply(nn, format, digits=dig))
      d=10         d=7          d=2      d=1     d=0     
 [1,] "123456"     "123456"     "123456" "1e+05" "1.e+05"
 [2,] "12345.6"    "12345.6"    "12346"  "12346" "1.e+04"
 [3,] "1234.56"    "1234.56"    "1235"   "1235"  "1235"  
 [4,] "123.456"    "123.456"    "123"    "123"   "123"   
 [5,] "12.3456"    "12.3456"    "12"     "12"    "12"    
 [6,] "1.23456"    "1.23456"    "1.2"    "1"     "1"     
 [7,] "0.123456"   "0.123456"   "0.12"   "0.1"   "0"     
 [8,] "0.0123456"  "0.0123456"  "0.012"  "0.01"  "0"     
 [9,] "0.00123456" "0.00123456" "0.0012" "0.001" "0"     


Regards,

Marc Schwartz



[Rd] prettyNum digits=0 not compatible with scientific notation
Marc Schwartz