[R] Format

Martin Maechler maechler at stat.math.ethz.ch
Mon May 14 09:22:35 CEST 2001


>>>>> "ChrisH" == Christian Hennig <fm3a004 at math.uni-hamburg.de> writes:

    ChrisH> Dear list,
    ChrisH> here is a matrix:
    >> m
    ChrisH> [,1]         [,2]         [,3]         [,4]
    ChrisH> [1,] 8222.631686 23222.298517 65644.171147 1.856273e+05
    ChrisH> [2,]   78.674051   199.885841   540.624003 1.502019e+03
    ChrisH> [3,]   19.182734    35.157578    78.674051 1.998858e+02
    ChrisH> [4,]   10.359269    13.009634    19.182734 3.515758e+01
    ChrisH> [5,]    8.155434     9.005421    10.359269 1.300963e+01
    ChrisH> [6,]    7.429700     8.036953     8.837021 1.007010e+01
    ChrisH> [7,]    4.364612     4.531727     4.719311 4.929875e+00

    ChrisH> Why do I get the fourth column in scientific notation, and how
    ChrisH> can it be made looking like the first three? (R 1.1.1 on Suse)

    ........

    ChrisH> *******************************************************************
    ChrisH> Christian Hennig

> print(m, digits = 15) # does not help
           V1           V2           V3           V4
1 8222.631686 23222.298517 65644.171147 1.856273e+05
2   78.674051   199.885841   540.624003 1.502019e+03
3   19.182734    35.157578    78.674051 1.998858e+02
4   10.359269    13.009634    19.182734 3.515758e+01
5    8.155434     9.005421    10.359269 1.300963e+01
6    7.429700     8.036953     8.837021 1.007010e+01
7    4.364612     4.531727     4.719311 4.929875e+00

> formatC(m, format = "f", digits = 8) # may be not quite yet what you want
  V1              V2               V3               V4               
1 "8222.63168600" "23222.29851700" "65644.17114700" "185627.30000000"
2 "78.67405100"   "199.88584100"   "540.62400300"   "1502.01900000"  
3 "19.18273400"   "35.15757800"    "78.67405100"    "199.88580000"   
4 "10.35926900"   "13.00963400"    "19.18273400"    "35.15758000"    
5 "8.15543400"    "9.00542100"     "10.35926900"    "13.00963000"    
6 "7.42970000"    "8.03695300"     "8.83702100"     "10.07010000"    
7 "4.36461200"    "4.53172700"     "4.71931100"     "4.92987500"     

> cm <- formatC(m, format = "f", digits = 8, width = 15)
> cm
  V1                V2                V3                V4               
1 "  8222.63168600" " 23222.29851700" " 65644.17114700" "185627.30000000"
2 "    78.67405100" "   199.88584100" "   540.62400300" "  1502.01900000"
3 "    19.18273400" "    35.15757800" "    78.67405100" "   199.88580000"
4 "    10.35926900" "    13.00963400" "    19.18273400" "    35.15758000"
5 "     8.15543400" "     9.00542100" "    10.35926900" "    13.00963000"
6 "     7.42970000" "     8.03695300" "     8.83702100" "    10.07010000"
7 "     4.36461200" "     4.53172700" "     4.71931100" "     4.92987500"
> print(cm, quote = FALSE)
  V1              V2              V3              V4             
1   8222.63168600  23222.29851700  65644.17114700 185627.30000000
2     78.67405100    199.88584100    540.62400300   1502.01900000
3     19.18273400     35.15757800     78.67405100    199.88580000
4     10.35926900     13.00963400     19.18273400     35.15758000
5      8.15543400      9.00542100     10.35926900     13.00963000
6      7.42970000      8.03695300      8.83702100     10.07010000
7      4.36461200      4.53172700      4.71931100      4.92987500
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list