[R] is there a formatted output in R?
tlumley at u.washington.edu
Sat Mar 11 01:59:42 CET 2006
On Fri, 10 Mar 2006, Michael wrote:
> Oh yeah, it worked... I got it typed wrong in R console... that's why...
> but why is cat() preferred?
In this context, because it translates the \n to a newline and doesn't
precede the output by .
So, if you are actually producing pretty output with sprintf() you
probably want cat(), but if you have a vector of formatted text and you
want to look at it (as data), print() would be better.
> On 3/10/06, Thomas Lumley <tlumley at u.washington.edu> wrote:
>> On Fri, 10 Mar 2006, Michael wrote:
>>> something like "sprintf" in C?
>>> so I can do:
>>> print(sprintf("the correct result is %3.4f\n", myresult));
>> Did you try this line of code? It actually works in R, although you would
>> probably prefer cat() instead of print().
>>> Also, I am desperately looking for a "clear console screen" function in
>>> thanks a lot!
>>> [[alternative HTML version deleted]]
>>> R-help at stat.math.ethz.ch mailing list
>>> PLEASE do read the posting guide!
>> Thomas Lumley Assoc. Professor, Biostatistics
>> tlumley at u.washington.edu University of Washington, Seattle
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-help