From: <kwright68_at_gmail.com>
Date: Mon 21 Nov 2005 - 17:13:36 GMT

Full_Name: Kevin Wright
Version: 2.2.0
OS: Windows 2000
Submission from: (NULL) (170.54.58.4)

Apologies if my expectations (or reading of the man page) are incorrect.

I seem unable to left-justify exponential format numbers. There appears to always be an extra space inserted to the left.

Using the example from the formatC help page:

R> xx <- pi * 10^(-5:4)

R> cbind(formatC(xx, wid = 9, flag = "-"))

[,1]
[1,] " 3.142e-05"
[2,] "0.0003142"
[3,] "0.003142 "
[4,] "0.03142 "
[5,] "0.3142 "
[6,] "3.142 "
[7,] "31.42 "
[8,] "314.2 "
[9,] "3142 "

[10,] " 3.142e+04"

# What does R want to do by default?
# Exponential numbers have a leading space

R> formatC(xx)
[1] " 3.142e-05" "0.0003142" "0.003142" "0.03142" "0.3142"
[6] "3.142" "31.42" "314.2" "3142" " 3.142e+04"

# Maybe space is reserved for a +/- sign? Let's try formatting negative numbers
# Still an extra space before exponential numbers

R> cbind(formatC(-xx, wid = 9, flag = "-"))

[,1]
[1,] " -3.142e-05"
[2,] "-0.0003142"
[3,] "-0.003142"
[4,] "-0.03142 "
[5,] "-0.3142 "
[6,] "-3.142 "
[7,] "-31.42 "
[8,] "-314.2 "
[9,] "-3142 "

[10,] " -3.142e+04"

# Try to force left-justification using 'width=-1', # still no luck.

R> cbind(formatC(xx, wid = -1))

[,1]
[1,] " 3.142e-05"
[2,] "0.0003142"
[3,] "0.003142"
[4,] "0.03142"
[5,] "0.3142"
[6,] "3.142"
[7,] "31.42"
[8,] "314.2"
[9,] "3142"

[10,] " 3.142e+04"

R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue Nov 22 04:25:11 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT