Re: [R] Suppressing output (e.g. from cat)

From: Richard Pearson <richard.pearson_at_postgrad.manchester.ac.uk>
Date: Tue, 24 Jun 2008 16:25:39 +0100

Many thanks Brian and Hadley, the quiet function works well for me. Maybe a candidate for utils?

Best wishes

Richard.

hadley wickham wrote:

>>> Or:
>>>
>>> tc <- textConnection(NULL, "w")
>>> sink(tc)
>>> ...
>>> sink()
>>> close(tc)
>> That is a lot more expensive and subject to
>>
>>    o   Use of textConnection(NULL, mode="w") could segfault.
>>
>> (NEWS for 2.7.1).  Output textConnections are convenient, but have quite a
>> lot of overhead since they need to keep the character vector current.

>
> That's true and I hadn't considered the speed issue. It would be nice
> to have an analogue to capture.output though. Maybe:
>
> quiet <- function(x) {
> sink(tempfile())
> on.exit(sink())
> invisible(force(x))
> }
>
> ?
>
> Hadley
>
>
-- 
Richard D. Pearson             richard.pearson_at_postgrad.manchester.ac.uk
School of Computer Science,    http://www.cs.man.ac.uk/~pearsonr
University of Manchester,      Tel: +44 161 275 6178
Oxford Road,                   Mob: +44 7971 221181
Manchester M13 9PL, UK.        Fax: +44 161 275 6204

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 24 Jun 2008 - 15:54:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 24 Jun 2008 - 16:30:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive