R/sinkReset.R

#' Resets any sink connections
#' 
#' Resets any sinky connections.  This makes the appropriate number of calls to sink
#' so that no matter how many diversions there have been the output
#' will be go to standard out once more.
#' 
#' closeAllConnections() is a better alternative.
#' 
#' @references \url{http://stackoverflow.com/a/18730656/1003565}
#' @export
#' @examples
#' sink("fakefileasdfasdfasdf.txt")
#' 2 + 2 # this will get sent to fakefileasdfasdfasdf.txt
#' sink("anotherfakefile.txt")
#' 3 + 3 # sent to anoterfakefile.txt
#' sinkReset()
#' 2 + 2 # results should display in console
sinkReset <- function(){
    for(i in seq_len(sink.number())){
        sink(NULL)
    }
}
Dasonk/Dmisc documentation built on May 6, 2019, 1:36 p.m.