Rev 6575 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
R : Copyright 1999, The R Development Core TeamVersion 0.90.0 Under development (unstable) (November 16, 1999)R is free software and comes with ABSOLUTELY NO WARRANTY.You are welcome to redistribute it under certain conditions.Type "?license" or "?licence" for distribution details.R is a collaborative project with many contributors.Type "?contributors" for a list.Type "demo()" for some demos, "help()" for on-line help, or"help.start()" for a HTML browser interface to help.Type "q()" to quit R.> #### Testing print(), format() and the like --- mainly with numeric()> ####> #### to be run as> ####> #### R < print-tests.R >& print-tests.out-__version__> #### == (csh)> opt.conformance <- 0>> if(!is.R())options(echo = T, warn = 1)#-- for Splus> print(search())#---- for Splus[1] ".GlobalEnv" "Autoloads" "package:base">> DIG <- function(d) if(missing(d)) options('digits')$dig else+ options(digits=as.integer(d))>> DIG(7)#-- the default; just to make sure ...> options(width = 200)>> n1 <- 2^(4*1:7)> i1 <- as.integer(n1)>> v1 <- 2^c(-12, 2*(-4:-2),3,6,9)> v2 <- v1^(63/64)>> v3 <- pi*100^(-1:3)> v4 <- (0:2)/1000 + 1e-10 #-- tougher one>> digs1 <- c(1,2*(1:5),11:16) # 20: platform dependent;> # 30 gives ERROR : options(digits=30)> digs2 <- c(1:20)#,30) gives 'error' in R: ``print.default(): invalid digits..''>> all(i1 == n1)# TRUE[1] TRUE> i1# prints nicely[1] 16 256 4096 65536 1048576 16777216 268435456> n1# did not; does now (same as 'i1')[1] 16 256 4096 65536 1048576 16777216 268435456>> round (v3, 3)#S+ & R 0.49:[1] 0.031 3.142 314.159 31415.927 3141592.654> ##[1] 0.031 3.142 314.159 31415.927 3141592.654> signif(v3, 3)[1] 3.14e-02 3.14e+00 3.14e+02 3.14e+04 3.14e+06> ##R.49: [1] 0.0314 3.1400 314.0000 31400.0000 3140000.0000> ##S+ [1] 3.14e-02 3.14e+00 3.14e+02 3.14e+04 3.14e+06>> ###----------------------------------------------------------------> ##- Date: Tue, 20 May 97 17:11:18 +0200>> ##- From: Martin Maechler <maechler@stat.math.ethz.ch>> ##- To: R-devel@stat.math.ethz.ch> ##- Subject: R-alpha: print 'problems': print(2^30, digits=12); comments at start of function()> ##-> ##- Both of these bugs are not a real harm,> ##- however, they have been annoying me for too long ... ;-)> ##-> ##- 1)> print (2^30, digits = 12) #- WAS exponential form, unnecessarily -- now ok[1] 1073741824> formatC(2^30, digits = 12) #- shows you what you'd want above[1] " 1073741824">> ## S and R are now the same here; note that the problem also affects> ## paste(.) & format(.) :>> DIG(10); paste(n1); DIG(7)[1] "16" "256" "4096" "65536" "1048576" "16777216" "268435456">>> ## Assignment to .Options$digits: Does NOT work for print() nor cat()> for(i in digs1) { .Options$digits <- i; cat(i,":"); print (v1[-1]) }1 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+022 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+024 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+026 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+028 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0210 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0211 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0212 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0213 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0214 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0215 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0216 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+02>> ## using options() *does* things> for(i in digs1) { DIG(i); cat(i,":"); print (v3) }1 :[1] 3e-02 3e+00 3e+02 3e+04 3e+062 :[1] 3.1e-02 3.1e+00 3.1e+02 3.1e+04 3.1e+064 :[1] 3.142e-02 3.142e+00 3.142e+02 3.142e+04 3.142e+066 :[1] 3.14159e-02 3.14159e+00 3.14159e+02 3.14159e+04 3.14159e+068 :[1] 3.1415927e-02 3.1415927e+00 3.1415927e+02 3.1415927e+04 3.1415927e+0610 :[1] 3.141592654e-02 3.141592654e+00 3.141592654e+02 3.141592654e+04 3.141592654e+0611 :[1] 3.1415926536e-02 3.1415926536e+00 3.1415926536e+02 3.1415926536e+04 3.1415926536e+0612 :[1] 3.14159265359e-02 3.14159265359e+00 3.14159265359e+02 3.14159265359e+04 3.14159265359e+0613 :[1] 3.14159265359e-02 3.14159265359e+00 3.14159265359e+02 3.14159265359e+04 3.14159265359e+0614 :[1] 3.1415926535898e-02 3.1415926535898e+00 3.1415926535898e+02 3.1415926535898e+04 3.1415926535898e+0615 :[1] 3.14159265358979e-02 3.14159265358979e+00 3.14159265358979e+02 3.14159265358979e+04 3.14159265358979e+0616 :[1] 3.141592653589793e-02 3.141592653589793e+00 3.141592653589793e+02 3.141592653589793e+04 3.141592653589793e+06> for(i in digs1) { DIG(i); cat(i,":", formatC(v3, digits=i, width=8),"\n") }1 : 0.03 3 3e+02 3e+04 3e+062 : 0.031 3.1 3.1e+02 3.1e+04 3.1e+064 : 0.03142 3.142 314.2 3.142e+04 3.142e+066 : 0.0314159 3.14159 314.159 31415.9 3.14159e+068 : 0.031415927 3.1415927 314.15927 31415.927 3141592.710 : 0.03141592654 3.141592654 314.1592654 31415.92654 3141592.65411 : 0.031415926536 3.1415926536 314.15926536 31415.926536 3141592.653612 : 0.0314159265359 3.14159265359 314.159265359 31415.9265359 3141592.6535913 : 0.0314159265359 3.14159265359 314.159265359 31415.9265359 3141592.6535914 : 0.031415926535898 3.1415926535898 314.15926535898 31415.926535898 3141592.653589815 : 0.0314159265358979 3.14159265358979 314.159265358979 31415.9265358979 3141592.6535897916 : 0.03141592653589793 3.141592653589793 314.1592653589793 31415.92653589793 3141592.653589793>>> ## R-0.50: switches to NON-exp at 14, but should only at 15...> ## R-0.61++: doesn' switch at all (or at 20 only)> ## S-plus: does not switch at all..> for(i in digs1) { cat(i,":"); print(v1, digits=i) }1 :[1] 2e-04 4e-03 2e-02 6e-02 8e+00 6e+01 5e+022 :[1] 2.4e-04 3.9e-03 1.6e-02 6.2e-02 8.0e+00 6.4e+01 5.1e+024 :[1] 2.441e-04 3.906e-03 1.562e-02 6.250e-02 8.000e+00 6.400e+01 5.120e+026 :[1] 2.44141e-04 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+028 :[1] 2.4414062e-04 3.9062500e-03 1.5625000e-02 6.2500000e-02 8.0000000e+00 6.4000000e+01 5.1200000e+0210 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0211 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0212 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0213 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0214 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0215 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+0216 :[1] 2.44140625e-04 3.90625000e-03 1.56250000e-02 6.25000000e-02 8.00000000e+00 6.40000000e+01 5.12000000e+02>> ## R 0.50-a1: switches at 10 inst. 11> for(i in digs1) { cat(i,":"); print(v1[-1], digits=i) }1 :[1] 4e-03 2e-02 6e-02 8e+00 6e+01 5e+022 :[1] 3.9e-03 1.6e-02 6.2e-02 8.0e+00 6.4e+01 5.1e+024 :[1] 3.906e-03 1.562e-02 6.250e-02 8.000e+00 6.400e+01 5.120e+026 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+028 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0210 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0211 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0212 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0213 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0214 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0215 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+0216 :[1] 3.90625e-03 1.56250e-02 6.25000e-02 8.00000e+00 6.40000e+01 5.12000e+02>> for(i in digs1) { DIG(i); cat(i,":", formatC(v2, digits=i, width=8),"\n") }1 : 0.0003 0.004 0.02 0.07 8 6e+01 5e+022 : 0.00028 0.0043 0.017 0.065 7.7 60 4.6e+024 : 0.000278 0.00426 0.01667 0.06527 7.744 59.97 464.46 : 0.000278025 0.0042598 0.0166741 0.0652671 7.74425 59.9734 464.4498 : 0.00027802457 0.0042597958 0.016674069 0.065267111 7.7442472 59.973364 464.4485610 : 0.000278024569 0.004259795831 0.01667406876 0.0652671114 7.744247174 59.97336429 464.448556911 : 0.00027802456903 0.0042597958307 0.016674068761 0.065267111402 7.744247174 59.973364292 464.4485569312 : 0.000278024569032 0.00425979583072 0.0166740687606 0.0652671114017 7.74424717397 59.9733642915 464.44855692813 : 0.0002780245690324 0.004259795830724 0.01667406876058 0.06526711140171 7.744247173969 59.97336429153 464.448556928114 : 0.0002780245690324 0.0042597958307237 0.016674068760575 0.065267111401713 7.7442471739692 59.97336429153 464.448556928115 : 0.000278024569032395 0.00425979583072366 0.0166740687605754 0.0652671114017134 7.74424717396918 59.9733642915296 464.44855692810216 : 0.0002780245690323954 0.004259795830723663 0.01667406876057537 0.06526711140171336 7.744247173969177 59.9733642915296 464.4485569281021>> for(i in digs1) { cat(i,":"); print(v2, digits=i) } #-- exponential all thru1 :[1] 3e-04 4e-03 2e-02 7e-02 8e+00 6e+01 5e+022 :[1] 2.8e-04 4.3e-03 1.7e-02 6.5e-02 7.7e+00 6.0e+01 4.6e+024 :[1] 2.780e-04 4.260e-03 1.667e-02 6.527e-02 7.744e+00 5.997e+01 4.644e+026 :[1] 2.78025e-04 4.25980e-03 1.66741e-02 6.52671e-02 7.74425e+00 5.99734e+01 4.64449e+028 :[1] 2.7802457e-04 4.2597958e-03 1.6674069e-02 6.5267111e-02 7.7442472e+00 5.9973364e+01 4.6444856e+0210 :[1] 2.780245690e-04 4.259795831e-03 1.667406876e-02 6.526711140e-02 7.744247174e+00 5.997336429e+01 4.644485569e+0211 :[1] 2.7802456903e-04 4.2597958307e-03 1.6674068761e-02 6.5267111402e-02 7.7442471740e+00 5.9973364292e+01 4.6444855693e+0212 :[1] 2.78024569032e-04 4.25979583072e-03 1.66740687606e-02 6.52671114017e-02 7.74424717397e+00 5.99733642915e+01 4.64448556928e+0213 :[1] 2.780245690324e-04 4.259795830724e-03 1.667406876058e-02 6.526711140171e-02 7.744247173969e+00 5.997336429153e+01 4.644485569281e+0214 :[1] 2.7802456903240e-04 4.2597958307237e-03 1.6674068760575e-02 6.5267111401713e-02 7.7442471739692e+00 5.9973364291530e+01 4.6444855692810e+0215 :[1] 2.78024569032395e-04 4.25979583072366e-03 1.66740687605754e-02 6.52671114017134e-02 7.74424717396918e+00 5.99733642915296e+01 4.64448556928102e+0216 :[1] 2.780245690323954e-04 4.259795830723663e-03 1.667406876057537e-02 6.526711140171336e-02 7.744247173969177e+00 5.997336429152960e+01 4.644485569281021e+02> ## ^^^^^ digs2 (>= 18: PLATFORM dependent !!> for(i in digs1) { cat(i,":", formatC(v2, digits=i, width=8),"\n") }1 : 0.0003 0.004 0.02 0.07 8 6e+01 5e+022 : 0.00028 0.0043 0.017 0.065 7.7 60 4.6e+024 : 0.000278 0.00426 0.01667 0.06527 7.744 59.97 464.46 : 0.000278025 0.0042598 0.0166741 0.0652671 7.74425 59.9734 464.4498 : 0.00027802457 0.0042597958 0.016674069 0.065267111 7.7442472 59.973364 464.4485610 : 0.000278024569 0.004259795831 0.01667406876 0.0652671114 7.744247174 59.97336429 464.448556911 : 0.00027802456903 0.0042597958307 0.016674068761 0.065267111402 7.744247174 59.973364292 464.4485569312 : 0.000278024569032 0.00425979583072 0.0166740687606 0.0652671114017 7.74424717397 59.9733642915 464.44855692813 : 0.0002780245690324 0.004259795830724 0.01667406876058 0.06526711140171 7.744247173969 59.97336429153 464.448556928114 : 0.0002780245690324 0.0042597958307237 0.016674068760575 0.065267111401713 7.7442471739692 59.97336429153 464.448556928115 : 0.000278024569032395 0.00425979583072366 0.0166740687605754 0.0652671114017134 7.74424717396918 59.9733642915296 464.44855692810216 : 0.0002780245690323954 0.004259795830723663 0.01667406876057537 0.06526711140171336 7.744247173969177 59.9733642915296 464.4485569281021>> DIG(7)#-- the default; just to make sure ...>> N1 <- 10; N2 <- 7; n <- 8> x <- 0:N1> Mhyp <- rbind(phyper(x, N1, N2, n), dhyper(x, N1, N2, n))> Mhyp[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11][1,] 0 0.0004113534 0.01336898 0.1170300 0.4193747 0.7821884 0.9635952 0.99814891 1.00000000 1 1[2,] 0 0.0004113534 0.01295763 0.1036610 0.3023447 0.3628137 0.1814068 0.03455368 0.00185109 0 0> ##- [,1] [,2] [,3] [,4] [,5] [,6] [,7]> ##- [1,] 0 0.0004113534 0.01336898 0.117030 0.4193747 0.7821884 0.9635952> ##- [2,] 0 0.0004113534 0.01295763 0.103661 0.3023447 0.3628137 0.1814068> ##- [,8] [,9] [,10] [,11]> ##- [1,] 0.99814891 1.00000000 1 1> ##- [2,] 0.03455368 0.00185109 0 0>> m11 <- c(-1,1)> Mm <- pi*outer(m11, 10^(-5:5))> Mm <- cbind(Mm, outer(m11, 10^-(5:1)))> Mm[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13] [,14] [,15] [,16][1,] -3.141593e-05 -0.0003141593 -0.003141593 -0.03141593 -0.3141593 -3.141593 -31.41593 -314.1593 -3141.593 -31415.93 -314159.3 -1e-05 -1e-04 -0.001 -0.01 -0.1[2,] 3.141593e-05 0.0003141593 0.003141593 0.03141593 0.3141593 3.141593 31.41593 314.1593 3141.593 31415.93 314159.3 1e-05 1e-04 0.001 0.01 0.1> do.p <- TRUE> do.p <- FALSE> for(di in 1:10) {+ options(digits=di)+ cat(if(do.p)"\n",formatC(di,w=2),":", format.info(Mm),"\n")+ if(do.p)print(Mm)+ }1 : 6 0 12 : 8 1 13 : 9 2 14 : 10 3 15 : 11 4 16 : 12 5 17 : 13 6 18 : 14 7 19 : 15 8 110 : 16 9 1> ##-- R-0.49 (4/1997) R-0.50-a1 (7.7.97)> ##- 1 : 13 5 0 1 : 6 0 1> ##- 2 : 8 1 1 = 2 : 8 1 1> ##- 3 : 9 2 1 = 3 : 9 2 1> ##- 4 : 10 3 1 = 4 : 10 3 1> ##- 5 : 11 4 1 = 5 : 11 4 1> ##- 6 : 12 5 1 = 6 : 12 5 1> ##- 7 : 13 6 1 = 7 : 13 6 1> ##- 8 : 14 7 1 = 8 : 14 7 1> ##- 9 : 15 8 1 = 9 : 15 8 1> ##- 10 : 16 9 1 = 10 : 16 9 1>>> ##-- Ok now, everywhere> for(d in 1:9) {cat(d,":"); print(v4, digits=d) }1 :[1] 1e-10 1e-03 2e-032 :[1] 1e-10 1e-03 2e-033 :[1] 1e-10 1e-03 2e-034 :[1] 1e-10 1e-03 2e-035 :[1] 1e-10 1e-03 2e-036 :[1] 1e-10 1e-03 2e-037 :[1] 1e-10 1e-03 2e-038 :[1] 0.0000000001 0.0010000001 0.00200000019 :[1] 0.0000000001 0.0010000001 0.0020000001> DIG(7)>>> ###------------ Very big and very small (--> ./signif.R )> umach <- unlist(.Machine)[paste("double.x", c("min","max"), sep='')]> xmin <- umach[1]> xmax <- umach[2]> tx <- unique(outer(-1:1,c(.1,1e-3,1e-7)))# 7 values (out of 9)> tx <- unique(sort(c(outer(umach,1+tx))))# 11 values (out of 14)> tx <- tx[is.finite(tx)] #-- all kept> (txp <- tx[tx >= 1])#-- Positive exponent -- 4 values[1] 1.617924e+308 1.795895e+308 1.797693e+308 1.797693e+308> (txn <- tx[tx < 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>> ##------ Use Emacs screen width 134 ; Courier 12 ----> cat("dig| formatC(txp, d=dig)\n")dig| formatC(txp, d=dig)> 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")1 2e+308 2e+308 2e+308 2e+3082 1.6e+308 1.8e+308 1.8e+308 1.8e+3083 1.62e+308 1.8e+308 1.8e+308 1.8e+3084 1.618e+308 1.796e+308 1.798e+308 1.798e+3085 1.6179e+308 1.7959e+308 1.7977e+308 1.7977e+3086 1.61792e+308 1.7959e+308 1.79769e+308 1.79769e+3087 1.617924e+308 1.795895e+308 1.797693e+308 1.797693e+3088 1.6179238e+308 1.7958954e+308 1.797693e+308 1.7976931e+3089 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+30810 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693135e+30811 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931349e+30812 1.61792382138e+308 1.79589544173e+308 1.79769295509e+308 1.79769313486e+30813 1.617923821376e+308 1.795895441727e+308 1.797692955093e+308 1.797693134862e+30814 1.6179238213761e+308 1.7958954417275e+308 1.797692955093e+308 1.7976931348623e+30815 1.61792382137608e+308 1.79589544172745e+308 1.797692955093e+308 1.79769313486232e+30816 1.617923821376084e+308 1.795895441727453e+308 1.797692955093002e+308 1.797693134862316e+30817 1.6179238213760842e+308 1.7958954417274534e+308 1.7976929550930023e+308 1.7976931348623157e+308> cat("signif() behavior\n~~~~~~~~\n",+ "dig| formatC(signif(txp, dig=dig), dig = dig+2\n")signif() behavior~~~~~~~~dig| formatC(signif(txp, dig=dig), dig = dig+2> for(dig in 1:12)# 13:15 (not 16:18) is libc-dependent (Linux, see below)+ cat(formatC(dig,w=2), formatC(signif(txp, d=dig), dig=dig+2, wid=-26),"\n")1 1e+308 1e+308 1e+308 1e+3082 1.6e+308 1.7e+308 1.7e+308 1.7e+3083 1.62e+308 1.79e+308 1.79e+308 1.79e+3084 1.618e+308 1.796e+308 1.797e+308 1.797e+3085 1.6179e+308 1.7959e+308 1.7976e+308 1.7976e+3086 1.61792e+308 1.7959e+308 1.79769e+308 1.79769e+3087 1.617924e+308 1.795895e+308 1.797692e+308 1.797693e+3088 1.6179238e+308 1.7958954e+308 1.797693e+308 1.7976931e+3089 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+30810 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693134e+30811 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931348e+30812 1.61792382138e+308 1.79589544173e+308 1.79769295509e+308 1.79769313486e+308>> if(opt.conformance >= 1) {+ noquote(cbind(formatC(txp, dig = 22)))+ }>> cat("dig| formatC(signif(txn, d=dig)\n")dig| formatC(signif(txn, d=dig)> for(dig in 1:14)#15: Linux 2.1.120, libc-2.0.7 differs from Debian 2.0+ cat(formatC(dig,w=2), formatC(signif(txn, d=dig), dig=dig+2, wid=-20),"\n")1 2e-308 2e-308 2e-308 2e-308 2e-308 2e-308 2e-3082 2e-308 2.2e-308 2.2e-308 2.2e-308 2.2e-308 2.2e-308 2.4e-3083 2e-308 2.22e-308 2.23e-308 2.23e-308 2.23e-308 2.23e-308 2.45e-3084 2.003e-308 2.223e-308 2.225e-308 2.225e-308 2.225e-308 2.227e-308 2.448e-3085 2.0026e-308 2.2228e-308 2.2251e-308 2.2251e-308 2.2251e-308 2.2273e-308 2.4476e-3086 2.00257e-308 2.22285e-308 2.22507e-308 2.22507e-308 2.22507e-308 2.2273e-308 2.44758e-3087 2.002566e-308 2.222849e-308 2.225074e-308 2.225074e-308 2.225074e-308 2.227299e-308 2.447581e-3088 2.0025665e-308 2.2228488e-308 2.2250736e-308 2.2250739e-308 2.2250741e-308 2.2272989e-308 2.4475812e-3089 2.00256647e-308 2.22284878e-308 2.22507364e-308 2.22507386e-308 2.22507408e-308 2.22729893e-308 2.44758124e-30810 2.002566473e-308 2.222848785e-308 2.225073636e-308 2.225073859e-308 2.225074081e-308 2.227298932e-308 2.447581244e-30811 2.0025664727e-308 2.2228487846e-308 2.225073636e-308 2.2250738585e-308 2.225074081e-308 2.2272989324e-308 2.4475812444e-30812 2.00256647266e-308 2.22284878465e-308 2.225073636e-308 2.22507385851e-308 2.22507408101e-308 2.22729893237e-308 2.44758124436e-30813 2.002566472656e-308 2.222848784649e-308 2.225073636e-308 2.225073858507e-308 2.225074081015e-308 2.227298932366e-308 2.447581244358e-30814 2.0025664726565e-308 2.2228487846487e-308 2.2250736359998e-308 2.2250738585072e-308 2.2250740810146e-308 2.2272989323657e-308 2.4475812443579e-308>> ##-- Testing 'print' / digits :> for(dig in 1:11) { ## 12:13: libc-2.0.7 diff; 14:18 --- PLATFORM-dependent !!!+ cat("dig=",formatC(dig,w=2),": "); print(signif(txp, d=dig),dig=dig+2)+ }dig= 1 : [1] 1e+308 1e+308 1e+308 1e+308dig= 2 : [1] 1.6e+308 1.7e+308 1.7e+308 1.7e+308dig= 3 : [1] 1.62e+308 1.79e+308 1.79e+308 1.79e+308dig= 4 : [1] 1.618e+308 1.796e+308 1.797e+308 1.797e+308dig= 5 : [1] 1.6179e+308 1.7959e+308 1.7976e+308 1.7976e+308dig= 6 : [1] 1.61792e+308 1.79590e+308 1.79769e+308 1.79769e+308dig= 7 : [1] 1.617924e+308 1.795895e+308 1.797692e+308 1.797693e+308dig= 8 : [1] 1.6179238e+308 1.7958954e+308 1.7976930e+308 1.7976931e+308dig= 9 : [1] 1.61792382e+308 1.79589544e+308 1.79769296e+308 1.79769313e+308dig= 10 : [1] 1.617923821e+308 1.795895442e+308 1.797692955e+308 1.797693134e+308dig= 11 : [1] 1.6179238214e+308 1.7958954417e+308 1.7976929551e+308 1.7976931348e+308>> ##-- 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")> xa b1.0+ 1i 1.2+10i> (xx <- rbind(x, 2*x))a bx 1+1i 1.2+10i2+2i 2.4+20i> rbind(x0, 2*x0)[,1] [,2]x0 1+1i 1.2+10i2+2i 2.4+20i> x[4:6] <- c(Inf,Inf*c(-1,1i))> x + pia b4.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 + pia bx 4.141593+1i 4.341593+10i5.141593+2i 5.541593+20i> t(cbind(xx, xx+ 1i*c(1,pi)))xa 1.0+ 1i 2.0+ 2.000000ib 1.2+10i 2.4+20.000000ia 1.0+ 2i 2.0+ 5.141593ib 1.2+11i 2.4+23.141593i>>