sink(file = NULL, append = FALSE, type = c("output", "message"), split = FALSE) sink.number(type = c("output", "message"))
sink.number() gets how many diversions are in use.
sink.number(type="message") gets the number of connection currently being used for error
messages.
> sink("tp.txt")#writ all output to file tp.txt > for (i in 1:5) print(i); > sink()#stop sinking, =sink(NULL)
In the tp.txt, the content is:
[1] 1 [1] 2 [1] 3 [1] 4 [1] 5
> sink.number()
[1] 0
> for (i in 1:5) print(i)#no sinking, then print to screen
[1] 1 [1] 2 [1] 3 [1] 4 [1] 5
> unlink("tp.txt")#delete the file tp.txt