Format to a fixed format representation
formatFix
formats to fixed point number format.
It 'writes' x
with sign (" " or "-"), with before
decimals before the "." and with after
decimals after the ".". If after == 0
then the "." will be omitted.
There will always be at least one decimal digit before the "."
If before
is too small to represent x
: if
extend==TRUE
, the string will be extended, else a string
consisting of "*" of length before+after
will be given.
If abs(x) >= 10^8, values very near 10^k cannot be represented
exactly, so the normal format
will be used.
Names are retained. The vector or array structure will be preserved
formatFix(x,after=2,before=1,extend=TRUE)
x |
Real,the number to be represented. |
after |
integer, The number of decimals after ".". |
before |
Integer, the minimum number of decimals before ".". |
extend |
Logical, extend string if necessary. |
The string representing the fixed point format of x
.
Christian W. Hoffmann <christian@echoffmann.ch>
## Not run: xxbig <- c(1.2e9,3.51e23,6.72e120,NaN); xx <- c(0.001,92,exp(1),1000*pi) t(t(formatFix(c(-rev(xxbig),-rev(xx),0,NA,xx,xxbig),0,3) )) #> [1] " NaN" "-7e+120" " -4e+23" " -1e+09" " -3142" " -3" " -92" #> [8] " -0" " 0" " NA" " 0" " 92" " 3" " 3142" #> [15] " 1e+09" " 4e+23" " 7e+120" " NaN" t(t(formatFix(c(-rev(xxbig),-rev(xx),0,NA,xx,xxbig),0,3,FALSE) )) #> [1] "NaN" "***" "***" "***" "***" " -3" "-92" " -0" " 0" " NA" " 0" " 92" #> [13] " 3" "***" "***" "***" "***" "NaN" formatFix(c(-rev(xxbig),-rev(xx),0,NA,xx,xxbig),6,3) #> [1] " NaN" " -6.72e+120" " -3.51e+23" " -1.2e+09" "-3141.592654" #> [6] " -2.718282" " -92.000000" " -0.001000" " 0.000000" " NA" #> [11] " 0.001000" " 92.000000" " 2.718282" " 3141.592654" " 1.2e+09" #> [16] " 3.51e+23" " 6.72e+120" " NaN" formatFix(c(-rev(xxbig),-rev(xx),0,NA,xx,xxbig),6,3,FALSE) #> [1] " NaN" "-6.72e+120" " -3.51e+23" " -1.2e+09" "**********" #> [6] " -2.718282" "-92.000000" " -0.001000" " 0.000000" " NA" #> [11] " 0.001000" " 92.000000" " 2.718282" "**********" " 1.2e+09" #> [16] " 3.51e+23" " 6.72e+120" " NaN" ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.