\Header{capture.output}{Send output to a character string or file}
\keyword{utilities}{capture.output}
\begin{Description}\relax
Evaluates its arguments with the output being returned as a character
string or sent to a file. Related to \code{\Link{sink}} in the same
way that \code{\Link{with}} is related to \code{\Link{attach}}.
\end{Description}
\begin{Usage}
\begin{verbatim}
capture.output(..., file = NULL, append = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{...}] Expressions to be evaluated
\item[\code{file}] A file name or a connection, or \code{NULL} to return
the output as a string. If the connection is not open it will be
opened and then closed on exit.
\item[\code{append}] Append or overwrite the file? 
\end{ldescription}
\end{Arguments}
\begin{Value}
A character string, or \code{NULL} if a \code{file} argument was
supplied.
\end{Value}
\begin{SeeAlso}\relax
\code{\Link{sink}}, \code{\Link{textConnection}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
require(stats)
glmout <- capture.output(example(glm))
glmout[1:5]
capture.output(1+1, 2+2)
capture.output({1+1; 2+2})
## Not run: 
## on Unix with enscript available
ps <- pipe("enscript -o tempout.ps","w")
capture.output(example(glm), file=ps)
close(ps)
## End(Not run)
\end{ExampleCode}
\end{Examples}

