[R] sprintf

From: J.M. Breiwick <jeff.breiwick_at_noaa.gov>
Date: Sat 18 Feb 2006 - 07:01:56 EST


I want to use sprintf with vectors whose lengths vary. As an example: x = c(2,4,6,10)
sprintf("%i%5f%5f%5f",x[1],x[2],x[3],x[4]) works. But if I have to compute the length of x within a function then I cannot list all for format codes and sprintf apparently will not accept just "x" - it wants one value for each format code as in the above example. Does anyone know a way to handle this? And is there a way to repeat the format code like in Fortran (e.g. 5F4.1)? Thanks.

Jeff B.

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Feb 18 07:09:10 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:34 EST