[R] how to specify format of floats for the output file

Henrik Bengtsson hb at maths.lth.se
Thu Aug 21 23:05:33 CEST 2003

sprintf() returns a character string that you then can write to file using
cat() or some of its friends.

Henrik Bengtsson

Dept. of Mathematical Statistics @ Centre for Mathematical Sciences 
Lund Institute of Technology/Lund University, Sweden (+2h UTC)
+46 46 2229611 (off), +46 708 909208 (cell), +46 46 2224623 (fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/~hb/

On Thu, 21 Aug 2003 ping-yin at uiowa.edu wrote:

> I'd like to write some numbers to an external file that looks "pretty" (e.g,
> decimal points aligned, same number of decimals). For example, if using
> sprintf(), "%5.1f" can be used to specify the format of the float to be printed
> on screen. How can I do the same if I want to write an output file instead? I
> have tried cat  and write.table, but none of them worked so far. 
> Thanks in advance,
> Ping
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

More information about the R-help mailing list