<	 1])#-- Negative exponent -- 7 values
[1] 2.002566e-308 2.222849e-308 2.225074e-308 2.225074e-308 2.225074e-308 2.227299e-308 2.447581e-308
> 
> x2 <- c(0.099999994, 0.2)
> x2 # digits=7: show all seven "9"s
[1] 0.09999999 0.20000000
> print(x2, digits=6) # 0.1 0.2 , not 0.10 0.20
[1] 0.1 0.2
> v <- 6:8; names(v) <- v; sapply(v, format.info, x=x2)
     6  7  8
[1,] 3 10 11
[2,] 1  8  9
[3,] 0  0  0
> 
> (z <- sort(c(outer(range(txn), 8^c(0,2:3)))))
[1] 2.002566e-308 2.447581e-308 1.281643e-306 1.566452e-306 1.025314e-305 1.253162e-305
> outer(z, 0:6, signif) # had NaN's till 1.1.1
       [,1]   [,2]     [,3]      [,4]       [,5]        [,6]         [,7]
[1,] 2e-308 2e-308 2.0e-308 2.00e-308 2.003e-308 2.0026e-308 2.00257e-308
[2,] 2e-308 2e-308 2.4e-308 2.45e-308 2.448e-308 2.4476e-308 2.44758e-308
[3,] 1e-306 1e-306 1.3e-306 1.28e-306 1.282e-306 1.2816e-306 1.28164e-306
[4,] 2e-306 2e-306 1.6e-306 1.57e-306 1.566e-306 1.5665e-306 1.56645e-306
[5,] 1e-305 1e-305 1.0e-305 1.03e-305 1.025e-305 1.0253e-305 1.02531e-305
[6,] 1e-305 1e-305 1.3e-305 1.25e-305 1.253e-305 1.2532e-305 1.25316e-305
> 
> olddig <- options(digits=14) # RH6.0 fails at 15
> z <- 1.234567891234567e27
> for(dig in 1:14) cat(formatC(dig,w=2),
+                      format(z, digits=dig), signif(z, digits=dig), "\n")
 1 1e+27 1e+27 
 2 1.2e+27 1.2e+27 
 3 1.23e+27 1.23e+27 
 4 1.235e+27 1.235e+27 
 5 1.2346e+27 1.2346e+27 
 6 1.23457e+27 1.23457e+27 
 7 1.234568e+27 1.234568e+27 
 8 1.2345679e+27 1.2345679e+27 
 9 1.23456789e+27 1.23456789e+27 
10 1.234567891e+27 1.234567891e+27 
11 1.2345678912e+27 1.2345678912e+27 
12 1.23456789123e+27 1.23456789123e+27 
13 1.234567891235e+27 1.234567891235e+27 
14 1.2345678912346e+27 1.2345678912346e+27 
> options(olddig)
> # The following are tests of printf inside formatC
> ##------ Use  Emacs screen width 134 ;	Courier 12 ----
> # cat("dig|  formatC(txp, d=dig)\n")
> # for(dig in 1:17)# about >= 18 is platform dependent [libc's printf()..].
> #     cat(formatC(dig,w=2), formatC(txp,		      dig=dig, wid=-29),"\n")
> # cat("signif() behavior\n~~~~~~~~\n",
> #     "dig|  formatC(signif(txp, dig=dig), dig = dig\n")
> # for(dig in 1:15)#
> #     cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig, wid=-26),"\n")
> 
> # if(opt.conformance >= 1) {
> #     noquote(cbind(formatC(txp, dig = 22)))
> # }
> 
> # cat("dig|  formatC(signif(txn, d = dig), dig=dig\n")
> # for(dig in 1:15)#
> #     cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig, wid=-20),"\n")
> 
> # ##-- Testing  'print' / digits :
> # for(dig in 1:13) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!
> #     cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+1)
> # }
> 
> ##-- Wrong alignment when printing character matrices with  quote = FALSE
> m1 <- matrix(letters[1:24],6,4)
> m1
     [,1] [,2] [,3] [,4]
[1,] "a"  "g"  "m"  "s" 
[2,] "b"  "h"  "n"  "t" 
[3,] "c"  "i"  "o"  "u" 
[4,] "d"  "j"  "p"  "v" 
[5,] "e"  "k"  "q"  "w" 
[6,] "f"  "l"  "r"  "x" 
> noquote(m1)
     [,1] [,2] [,3] [,4]
[1,] a    g    m    s   
[2,] b    h    n    t   
[3,] c    i    o    u   
[4,] d    j    p    v   
[5,] e    k    q    w   
[6,] f    l    r    x   
> 
> ##--- Complex matrices and named vectors :
> 
> x0 <- x <- c(1+1i, 1.2 + 10i)
> names(x) <- c("a","b")
> x
      a       b 
1.0+ 1i 1.2+10i
> (xx <-	rbind(x,  2*x))
     a       b
x 1+1i 1.2+10i
  2+2i 2.4+20i
> 	rbind(x0, 2*x0)
   [,1]    [,2]
x0 1+1i 1.2+10i
   2+2i 2.4+20i
> x[4:6] <- c(Inf,Inf*c(-1,1i))
> x  + pi
            a             b                                                         
4.141593+  1i 4.341593+ 10i            NA      Inf+  0i     -Inf+NaNi      NaN+Infi
> matrix(x + pi, 2)
             [,1]   [,2]      [,3]
[1,] 4.141593+ 1i     NA -Inf+NaNi
[2,] 4.341593+10i Inf+0i  NaN+Infi
> matrix(x + 1i*pi, 3)
               [,1]           [,2]
[1,] 1.0+ 4.141593i  Inf+3.141593i
[2,] 1.2+13.141593i -Inf+     NaNi
[3,]             NA  NaN+     Infi
> xx + pi
            a           b
x 4.141593+1i 4.34159+10i
  5.141593+2i 5.54159+20i
> t(cbind(xx, xx+ 1i*c(1,pi)))
        x               
a 1.0+ 1i 2.0+ 2.000000i
b 1.2+10i 2.4+20.000000i
a 1.0+ 2i 2.0+ 5.141593i
b 1.2+11i 2.4+23.141593i
> 
> #--- format checks after incorrect changes in Nov 2000
> zz <- data.frame("(row names)" = c("aaaaa", "b"), check.names = FALSE)
> format(zz)
  (row names)
1       aaaaa
2           b
> format(zz, justify = "left")
  (row names)
1       aaaaa
2       b    
> zz <- data.frame(a = I("abc"), b = I("def\"gh"))
> format(zz)
    a      b
1 abc def"gh
> # " (font-locking: closing the string above)
> 
> # test format.data.frame on former AsIs's.
> set.seed(321)
> dd <- data.frame(x = 1:5, y = rnorm(5), z = c(1, 2, NA, 4, 5))
> model <- glm(y ~ x, data = dd, subset = 1:4, na.action = na.omit)
> expand.model.frame(model, "z", na.expand = FALSE)
           y x z
1  1.7049032 1 1
2 -0.7120386 2 2
4 -0.1196490 4 4
> expand.model.frame(model, "z", na.expand = TRUE)
           y x  z
1  1.7049032 1  1
2 -0.7120386 2  2
3 -0.2779849 3 NA
4 -0.1196490 4  4
> 
> ## print.table() changes affecting summary.data.frame
> options(width=82)
> summary(attenu) # ``one line''
     event            mag           station         dist            accel        
 Min.   : 1.00   Min.   :5.000   117    :  5   Min.   :  0.50   Min.   :0.00300  
 1st Qu.: 9.00   1st Qu.:5.300   1028   :  4   1st Qu.: 11.32   1st Qu.:0.04425  
 Median :18.00   Median :6.100   113    :  4   Median : 23.40   Median :0.11300  
 Mean   :14.74   Mean   :6.084   112    :  3   Mean   : 45.60   Mean   :0.15422  
 3rd Qu.:20.00   3rd Qu.:6.600   135    :  3   3rd Qu.: 47.55   3rd Qu.:0.21925  
 Max.   :23.00   Max.   :7.700   (Other):147   Max.   :370.00   Max.   :0.81000  
                                 NA's   : 16                                     
> lst <- levels(attenu$station)
> levels(attenu$station)[lst == "117"] <- paste(rep(letters,3),collapse="")
> summary(attenu) # {2 + one long + 2 } variables
     event            mag       
 Min.   : 1.00   Min.   :5.000  
 1st Qu.: 9.00   1st Qu.:5.300  
 Median :18.00   Median :6.100  
 Mean   :14.74   Mean   :6.084  
 3rd Qu.:20.00   3rd Qu.:6.600  
 Max.   :23.00   Max.   :7.700  
                                
                                                                           station   
 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz:  5  
 1028                                                                          :  4  
 113                                                                           :  4  
 112                                                                           :  3  
 135                                                                           :  3  
 (Other)                                                                       :147  
 NA's                                                                          : 16  
      dist            accel        
 Min.   :  0.50   Min.   :0.00300  
 1st Qu.: 11.32   1st Qu.:0.04425  
 Median : 23.40   Median :0.11300  
 Mean   : 45.60   Mean   :0.15422  
 3rd Qu.: 47.55   3rd Qu.:0.21925  
 Max.   :370.00   Max.   :0.81000  
                                   
> ## in 1.7.0, things were split to more lines
> 
> ## format.default(*, nsmall > 0)  -- for real and complex
> 
> sf <- function(x, N=14) sapply(0:N, function(i) format(x,nsmall=i))
> sf(2)
 [1] "2"                "2.0"              "2.00"             "2.000"           
 [5] "2.0000"           "2.00000"          "2.000000"         "2.0000000"       
 [9] "2.00000000"       "2.000000000"      "2.0000000000"     "2.00000000000"   
[13] "2.000000000000"   "2.0000000000000"  "2.00000000000000"
> sf(3.141)
 [1] "3.141"            "3.141"            "3.141"            "3.141"           
 [5] "3.1410"           "3.14100"          "3.141000"         "3.1410000"       
 [9] "3.14100000"       "3.141000000"      "3.1410000000"     "3.14100000000"   
[13] "3.141000000000"   "3.1410000000000"  "3.14100000000000"
> sf(-1.25, 20)
 [1] "-1.25"                   "-1.25"                   "-1.25"                  
 [4] "-1.250"                  "-1.2500"                 "-1.25000"               
 [7] "-1.250000"               "-1.2500000"              "-1.25000000"            
[10] "-1.250000000"            "-1.2500000000"           "-1.25000000000"         
[13] "-1.250000000000"         "-1.2500000000000"        "-1.25000000000000"      
[16] "-1.250000000000000"      "-1.2500000000000000"     "-1.25000000000000000"   
[19] "-1.250000000000000000"   "-1.2500000000000000000"  "-1.25000000000000000000"
> 
> oDig <- options(digits= 3)
> sf(pi)
 [1] "3.14"             "3.14"             "3.14"             "3.142"           
 [5] "3.1416"           "3.14159"          "3.141593"         "3.1415927"       
 [9] "3.14159265"       "3.141592654"      "3.1415926536"     "3.14159265359"   
[13] "3.141592653590"   "3.1415926535898"  "3.14159265358979"
> sf(1.2e7)
 [1] "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07"
 [8] "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07" "1.2e+07"
[15] "1.2e+07"
> sf(1.23e7)
 [1] "12300000"                "12300000.0"              "12300000.00"            
 [4] "12300000.000"            "12300000.0000"           "12300000.00000"         
 [7] "12300000.000000"         "12300000.0000000"        "12300000.00000000"      
[10] "12300000.000000000"      "12300000.0000000000"     "12300000.00000000000"   
[13] "12300000.000000000000"   "12300000.0000000000000"  "12300000.00000000000000"
> s <- -0.01234
> sf(s)
 [1] "-0.0123"           "-0.0123"           "-0.0123"          
 [4] "-0.0123"           "-0.0123"           "-0.01234"         
 [7] "-0.012340"         "-0.0123400"        "-0.01234000"      
[10] "-0.012340000"      "-0.0123400000"     "-0.01234000000"   
[13] "-0.012340000000"   "-0.0123400000000"  "-0.01234000000000"
> 
> sf(pi + 2.2i)
 [1] "3.14+2.2i"                          "3.14+2.2i"                         
 [3] "3.14+2.20i"                         "3.142+2.200i"                      
 [5] "3.1416+2.2000i"                     "3.14159+2.20000i"                  
 [7] "3.141593+2.200000i"                 "3.1415927+2.2000000i"              
 [9] "3.14159265+2.20000000i"             "3.141592654+2.200000000i"          
[11] "3.1415926536+2.2000000000i"         "3.14159265359+2.20000000000i"      
[13] "3.141592653590+2.200000000000i"     "3.1415926535898+2.2000000000000i"  
[15] "3.14159265358979+2.20000000000000i"
> sf(s + pi*1i)
 [1] "-0.01+3.14i"                         "-0.01+3.14i"                        
 [3] "-0.01+3.14i"                         "-0.012+3.142i"                      
 [5] "-0.0123+3.1416i"                     "-0.01234+3.14159i"                  
 [7] "-0.012340+3.141593i"                 "-0.0123400+3.1415927i"              
 [9] "-0.01234000+3.14159265i"             "-0.012340000+3.141592654i"          
[11] "-0.0123400000+3.1415926536i"         "-0.01234000000+3.14159265359i"      
[13] "-0.012340000000+3.141592653590i"     "-0.0123400000000+3.1415926535898i"  
[15] "-0.01234000000000+3.14159265358979i"
> 
> options(oDig)
> 
> e1 <- tryCatch(options(max.print=Inf), error=function(e)e)
Warning message:
In options(max.print = Inf) : NAs introduced by coercion to integer range
> e2 <- tryCatch(options(max.print= 0),  error=function(e)e)
> stopifnot(inherits(e1, "error"))
> 
> 
> ## Printing of "Date"s
> options(width = 80)
> op <- options(max.print = 500)
> dd <- as.Date("2012-03-12") + -10000:100
> writeLines(t1 <- tail(capture.output(dd)))
[476] "1986-02-12" "1986-02-13" "1986-02-14" "1986-02-15" "1986-02-16"
[481] "1986-02-17" "1986-02-18" "1986-02-19" "1986-02-20" "1986-02-21"
[486] "1986-02-22" "1986-02-23" "1986-02-24" "1986-02-25" "1986-02-26"
[491] "1986-02-27" "1986-02-28" "1986-03-01" "1986-03-02" "1986-03-03"
[496] "1986-03-04" "1986-03-05" "1986-03-06" "1986-03-07" "1986-03-08"
 [ reached getOption("max.print") -- omitted 9601 entries ]
> l6 <- length(capture.output(print(dd, max = 600)))
> options(op)
> t2 <- tail(capture.output(print(dd, max = 500)))
> stopifnot(identical(t1, t2), l6 == 121)
> ## not quite consistent in R <= 2.14.x
> 
> 
