[R] problem of fixed-formated output using sprintf

YIHSU CHEN yschen at jhu.edu
Tue Jul 11 18:09:48 CEST 2006

Dear R users:

I'm trying to generate a output file with fixed format using function "sprintf" in R. However, the execution time in R is very long even the toy data (smaller size df) seems to work fine. The syntax that I used is as follows:

df.fmt <- sprintf("%2s%2s%2.4f", df$v1, df$v2, df$v3)
write.table(df.fmt, output.name,...)  

The actual dataset is a df with the dimention of 67944 by 34. I'm wondering whether there is an elegant way of doing it. I would like output in a txt file. 

Many thanks.

Yihsu Chen
The Johns Hopkins University

More information about the R-help mailing list