Re: [R] Formatting significant digits with trailing zeros

2003-03-14 Thread Tony Plate
Does this do what you want? > x <- c(2.503,2.477,0.1204) > sapply(signif(x,3), sprintf, fmt="%#.3g") [1] "2.50" "2.48" "0.120" > This will give you scientific notation for very large or small numbers. At Friday 02:17 PM 3/14/2003 -0800, Don MacQueen wrote: >I need a function like signif(), bu

[R] Formatting significant digits with trailing zeros

2003-03-14 Thread Don MacQueen
I need a function like signif(), but returns the rounded values as character strings, formatted with trailing zeros where appropriate. If anyone has one, I would sure appreciate a copy. Thanks -Don Details: signif() rounds a number to a specified number of significant digits, for example: