[R] sprintf
J.M. Breiwick
jeff.breiwick at noaa.gov
Fri Feb 17 21:01:56 CET 2006
Hi,
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.
More information about the R-help
mailing list