From tplate at acm.org  Tue Jul 25 19:25:02 2006
From: tplate at acm.org (Tony Plate)
Date: Tue, 25 Jul 2006 11:25:02 -0600
Subject: [Rd] obscure bug in format.default?
Message-ID: <44C653EE.7060008@acm.org>

Output from format.default sometimes has whitespace around it when using 
big.mark="," and trim=TRUE.  E.g.:

 > # works ok as long as big.mark is not actually used:
 > format(c(-1,1,10,999), big.mark=",", trim=TRUE)
[1] "-1"  "1"   "10"  "999"
 > # but if big.mark is used, output is justified and not trimmed:
 > format(c(-1,1,10,999,1e6), big.mark=",", trim=TRUE)
[1] "       -1" "        1" "       10" "      999" "1,000,000"
 >

I am unable to come up with any interpretation of the documentation for 
format.default under which this output could be considered correct, so I 
suspect this behavior should be classified as a bug.

The last call to 'prettyNum' in format.default has the argument

   preserve.width = "common"

If this is changed to

   preserve.width = if (trim) "individual" else "common"

then output is formatted correctly in the case above.

-- Tony Plate

 > sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32

attached base packages:
[1] "methods"   "stats"     "graphics"  "grDevices" "utils"     "datasets"
[7] "base"
 >



[Rd] obscure bug in format.default?
Tony Plate