[R] Suppressing output (e.g. from cat)
hadley wickham
h.wickham at gmail.com
Tue Jun 24 15:03:24 CEST 2008
>> 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
--
http://had.co.nz/
More information about the R-help
mailing list