On Sep 10, 2010, at 10:05 PM, Peng, C wrote:


I mean to display 001,010, ..., as there are. In other words, whether there
is a function, say func(), such that func(001,010) displays 001, 010.

Not hard to construct one, but does not behave properly in the sub- unity decimal range. Not surprising. It did better in the range of values from the integer class than I thought it would.

> func4 <- function(x) cat(sprintf("%05.0f", x))
> func4(10)
00010
> func5 <- function(x) cat(sprintf("%05.0f", x))
> func5(100)
00100
> func5(100000)
100000
> func5(100000000)
100000000
> func5(0.001)
00000
> func5(-3)
-0003
> func5(-3000000)
-3000000

--
David.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to