Skip to content
Prev 302234 / 398503 Next

Formatting numbers for display

David Winsemius wrote
How about this to get rid of leading space:

form3 <- function (x) sub("^ +","", switch(findInterval(x, c( 0, 1, 10^7,
Inf)),
                                    format(x, digits=3),
                                    formatC(x, width=8,  format="f", 
drop0trailing=FALSE),
                                    trunc(x) )
                         )

Berend




--
View this message in context: http://r.789695.n4.nabble.com/Formatting-numbers-for-display-tp4638991p4639018.html
Sent from the R help mailing list archive at Nabble.com.