Skip to content
Prev 86724 / 398513 Next

sprintf

On Fri, 2006-02-17 at 12:01 -0800, J.M. Breiwick wrote:
Is the format of the vector 'x' predictable?  In other words, will the
first element always be printed as an integer with the rest (of unknown
length) printed as floats?

Keep in mind that sprintf() is vectorized.

So:

x <- c(2, 4, 6, 10)
[1] "2"         "4.000000"  "6.000000"  "10.000000"
[1]  2  4  6  8 10 12 14 16 18 20

# Same code here
[1] "2"         "4.000000"  "6.000000"  "8.000000"  "10.000000"
 [6] "12.000000" "14.000000" "16.000000" "18.000000" "20.000000"


Does that get what you want?

BTW, please do not create a new post by responding to a different
thread. It plays havoc with the list archive making it difficult to
search for your post and any replies.

HTH,

Marc Schwartz