capture.output
Send output to a character string or file

Description

Captures the output from evaluated expressions. The output lines are either sent to a file or returned as elements of a character vector.

Usage

capture.output(..., file = NULL, append = FALSE)

Arguments

... expressions to be evaluated.
file the file or connection to where the output is written. If file is NULL (the default), capture.output returns a character vector.
append logical flag: if TRUE, the output is appended to file. If FALSE (the default), the output overwrites the contents of file.
Value
Side Effects
If file is a character string, the output is written to that file. If the file exists and append is TRUE, the output is appended to the end of the file.
If file is a connection, the output is written to the connection, and the append argument is ignored.
See Also
cat, sink
Examples
capture.output(cat(1:3))
capture.output(data.frame(a=11:13, b=21:23))
capture.output(data.frame(a=11:13, b=21:23), file="dataframe.txt")
Package utils version 4.0.0-28
Package Index